PDA

View Full Version : Looping an Animation a Specific Number of Times


PixelPilot
01-12-2009, 09:23 PM
Hi
Is it possible to suggest an amount of times an animation loops before moving further along the timeline?
Thanks
PixelPilot
:confused:

yxip
01-12-2009, 09:40 PM
This is how I would do it in Actionscript 2.0.
This code would be pasted in the actions window for the last frame of the animation you want to loop.

if (loopCount == undefined) {
var loopCount:Number = 0;
}
loopCount++;
trace("The value of loopCount is currently: " + loopCount);
if (loopCount >= 3) {
gotoAndPlay(10);
} else {
gotoAndPlay(1);
}

loopCount is a variable that keeps track of how many times the animation has played. If the loopCount is greater than or equal to 3, it goes to the first frame of your next animation (right now it says frame 10). Otherwise, it goes back to the first frame (Frame 1) and starts over.

This would be pretty simple to convert to Actionscript 3 too - it's almost the same with a few slight differences.

I hope that helps!

-Taryn

PixelPilot
01-12-2009, 09:41 PM
Hey thanks I will give this a go.

PixelPilot
01-12-2009, 09:45 PM
Yep that worked out great.
Many thanks :)

yxip
01-13-2009, 12:12 AM
I'm glad I could help!