Jump to content


[SOLVED] TweenMax.staggerTo... Last element of array starts tweening?

Recommended Posts

Hey folks,


maybe it's that I am blind, or just an idiot, but how can I get the moment when the last element of the (staggerTo) array starts tweening? I tried getTweensOf and all kinds of workarounds, but I failed :(


My example:

TweenMax.staggerTo(stepArray, tweenSpeed, {alpha:1, scaleX:1.5, scaleY:1.5, dropShadowFilter:{blurX:15, blurY:15, distance:5, alpha:0.33}, ease:Cubic.easeInOut, onComplete:tweenScaleDown, onCompleteParams:["{self}"]}, stepStaggerAmount);



Sorry if that's a dumb question, but I tried stuff for hours now and cant get it.




Link to comment
Share on other sites

Hi Lasercode,


Interesting challenge, not dumb at all. I don't think any tween is ever aware of its position in the Array that staggerTo creates. But you can analyze each tween's target and see if it is the same as the last item in the array of objects that you pass into staggerTo.


I tried to keep the code as general as possible, meaning it should work on any staggerTo and doesn't require attaching any additional data to the object's being tweened.



import com.greensock.*;

var mcs:Array = [mc1, mc2];

//use onstartParams to send a refrence to the individual tween and the array that its target belongs to
TweenMax.staggerTo(mcs, 1, {x:400, onstart:onstartHandler, onstartParams:["{self}", mcs]}, .5);

function onstartHandler(tween:TweenLite, array):void{

//if the current tween's target is the last item in the array then do stuff
if(tween.target == array[array.length-1]){
trace("last tween has started");
tween.target.rotation = 45;


I've attached CS5 fla and swf (use your GSAP v12 files)


*note in the code above, onstart and onstartParams should have upper-case S. Forums have a little issue.


Link to comment
Share on other sites

Here's one other idea that utilizes v12's eventCallback() method:



var mcs:Array = [mc1, mc2];

var tweens:Array = TweenMax.staggerTo(mcs, 1, {x:400}, .5);
tweens[tweens.length - 1].eventCallback("onstart", onstartHandler);

function onstartHandler():void {
trace("last tween started");


(note: for some silly reason, the forums software seems to be forcing the "S" in "onstart" to be lowercase in the examples above, but it should be uppercase)

  • Like 1
Link to comment
Share on other sites

Completely understood. The onstart Event was the main hint that I just didnt think about. Thanks!


Just wanted to say, that this is probably the best quality forum I ve seen in a looong while. Plus GSAP just rules.


Thank you - again!

  • Like 2
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.