Jump to content
Search Community

[SOLVED] onComplete with yoyo repeat [as2]

hexobolic test
Moderator Tag

Recommended Posts

I have a container that loads in an image that im trying to call each time the tween is completed, but seems to be hanging up if I add a yoyo and repeat values into the parameters. Is there something Im missing or doing wrong? It works fine with out the repeat. Would there be another way to do this? Thanks

import com.greensock.TweenMax;
var imgNum:Number = 0;
var imgLimit:Number = 1;
var imgPath:String = "img";
var imgArray:Array = new Array("/card11.png","/card14.png");
container.loadMovie(imgPath+imgArray[0]);
TweenMax.to(container,1,{_x:container._width*-1,delay:5,yoyo:true,repeat:-1,repeatDelay:1,onComplete:loadAsset});
function loadAsset(num:Number):Void{ 
imgNum++ trace(imgNum); 
if(imgNum>imgLimit){
imgNum=0;
}
switch (num){
case 0:  
container.loadMovie(imgPath+imgArray[1]); 
 break;  
case 1:  
container.loadMovie(imgPath+imgArray[2]); 
 break;  
} 
}
Link to comment
Share on other sites

The problem is that you are repeating your tween infinitely (-1) which means it never ends or fires onComplete. onComplete only fires when all iterations are complete.

 

Does using onRepeat:loadAssets work for you?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...