This video tutorial will show you how to make a Flash movie loop a certain number of times. With very basic ActionScript you can literally count how many times your animation has played and stop when the counter reaches a certain point.
The code from this example can very easily be copied and pasted into any document. What you choose to do when your animation is done playing is up to YOU!
Here is some code to steal for your own use:
ActionScript 2
Frame 1:
var count:Number = 0; var maxTimesToPlay:Number = 3;
Last Frame of Animation:
count++;
count_txt.text = count;
if(count == maxTimesToPlay){
gotoAndPlay("allDone");
}else{
gotoAndPlay(2);
}
ActionScript 3
Frame 1:
var count:Number = 0; var maxTimesToPlay:Number = 3;
Last Frame of Animation:
count++;
count_txt.text = String(count);
if(count == maxTimesToPlay){
gotoAndPlay("allDone");
}else{
gotoAndPlay(2);
}
* The only difference with the AS3 version is highlighted above. The count variable needs to be converted to a String before being displayed in the textfield.
Here are the Flash CS3 source files with AS2 and AS3 Versions: playMovieSetNumberOfTimes.zip







