Jump to content
Search Community

a lot of tweens and only one onComplete

matog test
Moderator Tag

Recommended Posts

hi, i have this code:

 

import com.greensock.*;
for(u=1;u<=10;u++){
TweenLite.to(eval("box"+u), 1, {_x:65,delay:0.6*u, onComplete:test});
}

function test(){
trace("times");
}

 

i want only a one trace to the last tween not the all tweens...

 

sorry for my english

 

thanks!

Link to comment
Share on other sites

You have several options:

 

1) Use TweenMax.allTo():

var myBoxes:Array = [box1, box2, box3, box4, box5, box6, box7, box8, box9, box10];
TweenMax.allTo(myBoxes, 1, {_x:65, delay:0.6}, 0.6, test);

 

-OR-

 

2) Use a TimelineLite with an onComplete:

 

var myTimeline:TimelineLite = new TimelineLite({onComplete:test});
for(u=1;u    myTimeline.insert( new TweenLite(eval("box"+u), 1, {_x:65}), 0.6 * u);
}

 

-OR-

 

3) Use a delayedCall() with a little extra time added to the end to make sure it fires AFTER all the others. I wouldn't really recommend this option, though, as it seems a little clunky to me :)

 

The nice thing about the TimelineLite is that you can control the entire sequence as a whole anytime with myTimeline.pause(), resume(), reverse(), play(), or restart(). Very flexible. Learn about TimelineLite at

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...