Jump to content


listener for the last item that is competed in a for loop

Recommended Posts



Is there a listener for the tweener, to listen for the last item in a loop that is finished?

I know you have onComplete, but that is for every tween.

For example:


for(var i:int = 0; i

var tile:Bitmap = tileArray;

TweenMax.to(tile, 5, {rotation:50, ease:Quad.easeOut, delay:0.02*i, onLastItemComplete:finishedWithAllItems });



function fishinedWithAllItems():void {

trace("the last tile finished with tweening");


Link to comment
Share on other sites

Hello Chrisatflash,


the short answer is no, there is no special listener as each tween has no idea that is part of a loop or what its position is in the loop.

inside the loop you could test to see if the value of i has reached a certain value and then create your last tween with an onComplete.


the great news is you don't need the loop and what you want to do is entirely possible. Since your tiles are already in an array just use TweenMax.allTo() like so



TweenMax.allTo(tileArray, 5, {rotation:50, ease:Quad.easeOut, onCompleteAll:finishedWithAllItems}, .02);


the line of code above can replace your entire loop. the .02 value at the end is the "stagger" amount which does the same thing as your previous delay:i*.02.





Link to comment
Share on other sites

Thanks Carl!

That is a great feature, i did not know about tweening an array, with TweenMax.allTo

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.