I have an issue with timing. I need to get grape MovieClip to the last frame within, for example, 10 seconds and then change animation, but onComplete fires up, after grape MC reached 11th frame! Is there some onTimeOut parameter, or something? I searched everywhere, tried a lot of workarounds, but nothing worked perfectly, it either finishes all animation before timer runs out or vice versa.
private function changeAnimation():void
{
if (currentGrapeNumber > 0)
{
TweenMax.killTweensOf(grapes["Grape" + currentGrapeNumber]);
if (currentGrapeNumber == 30)
{
return;
}
}
currentGrapeNumber++;
currentAnimation = TweenMax.to(grapes["Grape" + currentGrapeNumber], minutesPerGrape * 60, { frame:11, onComplete:changeAnimation });
}
EDIT 1: There is variable currentAnimation, because user can press pause button. I am trying to use own pausable timer class as workaround now, but still hope there is a way without using timers.
EDIT 2: Timer is involved, since app has a countdown.
Problem solved, I just added this to updateClock method:
private function updateClock(e:TimerEvent):void
{
secondsToSwitch--;
if (secondsToSwitch == 0)
{
secondsToSwitch = Math.round(minutesPerGrape * 60);
changeAnimation();
}
/**
* Function body
*/
}
And changed TweenMax.to() in changeAnimation method:
currentAnimation = TweenMax.to(grapes["Grape" + currentGrapeNumber], minutesPerGrape * 60, { frame:11 });
BUT. If you have an alternative or some misterious "onTimeOut" parameter in TweenMax - feel free to post it :)