When I use a for loop to tween a bunch of stuff and want to call a function on the complete of the least tween I’ve been using a conditional like so:
private function initTweenIcons():void
{
for (var i:int=0 ; i<_numIcons ; i++)
{
var temp:MovieClip = iconName[tweenOrder[i]];
if (i != _numIcons-1)
{
TweenMax.to(temp, tweenSpeed, {x:finalIconX[tweenOrder[i]], y:finalIconY[tweenOrder[i]], scaleX:.8, scaleY:.8, alpha:1, delay:i*.1, motionBlur:true, ease:Cubic.easeInOut});
}
else
{
TweenMax.to(temp, tweenSpeed, {x:finalIconX[tweenOrder[i]], y:finalIconY[tweenOrder[i]], scaleX:.8, scaleY:.8, alpha:1, delay:i*.1, motionBlur:true, ease:Cubic.easeInOut, onComplete:addListeners});
}
}
}
This works perfect but I’m wondering if there is an easier, more efficient way to do this. I know a timer could be used, aka delayedCall, but I figured this is more reliable just in case things don’t sync up perfectly.
Thanks!