I need to make an animation with numerous objects (around 500) flying from left to right, with different delay, duration and destination. However I need to run another function once all the objects have been already arrived at their destination.
I have tried to make an loop check every time when an object complete its flight. that is:
...
for(var i:int = 0; i < objs.length; i++)
Tweenlite.to(obj[i], duration, {delay:delay, x:destination.x, y:destination.y, onComplete:CheckAllComplete});
...
private function CheckAllComplete():void
{
for(var i:int =0 ;i < objs.length; i++)
{
if(Tweenlite.getTweensOf(obj[i]).length > 0)
return;
}
... // if all the flights complete
}
But I think it is very bulky and worse for CPU.
So, my question is, How can I consider all the objects as one tween and just add onComplete
to solve the problem?
something like:
var tween:*;
for(...)
tween.add(obj[i], duration, {...});
tween.onComplete = CompleteCallback;