0
votes

I'm a bit new to Flash. As I was developing my movie, I introduced 3 layers of sequential animation that I decided I wanted to loop X times. So I copied the frames, created a new Movie Clip symbol, pasted the frames into it, then deleted the original on the stage and dragged this new clip as an instance (my_animation) in its place. All good so far.

However, when I play the entire movie, my_animation looped indefinitely, so I added a stop() action into that movie clip. That worked - plays once. I then added the following as an action on the very last keyframe of the main scene to try and get my_animation to loop X times:

var i = 1;
for (i = 1;i < 5;i++)
{
    my_animation.play();
}
stop();

However, my_animation still only plays once. It does not appear to loop as I expect. I also tried replacing my_anmiation.play() with gotoAndPlay(117) where 117 is the frame containing the movie clip, but still the same.

Any help appreciated. Thanks

UPDATE: I added a trace(i); statement within the loop. In the Output tab, I see:

1
2
3
4

…etc. SO - my_animation is not firing within the loop.

1

1 Answers

0
votes

if you call my_animation.play(); with in "for loop" like that, it just calls 5 time consecutively and it just starts animation .

if you call my_animation.play(); during animation of my_animation nothing happens. it works if it has stopped...

. so you need to listen add callback for to understand that animation finished and you can start that animation again..

var animatedCount:int = 0;
my_animation.addFrameScript(my_animation.totalFrames-1, onMyAnimationEnds);
my_Animation.play();

function onMyAnimationEnds():void{
   animatedCount++;
   if(animatedCount < 5)
   {
      my_Animation.play();
   }
}

this will animate my_animation for 5 time...