We have all seen those banner ads that play two or three times and are replaced by another version of the ad. To loop the main timeline three times—this is a popular number for banner ads—declare a loop variable in frame 1 and initialize it to 0. Here’s how they do it:
this.stop();
This is the line that stops the playhead from moving forward, and it is also the line of code that can turn a millisecond into an eternity. If you stop the playhead, have a solid plan in place to get it back in motion.
var timelinePause:Timer = new Timer(2000, 1);
timelinePause.addEventListener(TimerEvent.TIMER, timerHandler);
timelinePause.start();
The first line tells Flash to create a Timer object. In ActionScript, when you use the class name followed by parentheses, you are creating what is called a constructor, which is a fancy term for an instance of a class. The numbers between the parentheses tell Flash the duration of the timer (2,000 milliseconds, or 2 seconds) and how often to wait around for that 2 seconds. The 1 means “only wait for it once."
The next line tells Flash what to do when the two seconds are up; which is to execute a function named timerHandler. The final line tells Flash to reset the timer, and start the timer if it isn’t already running.
function timerHandler(evt:Object):void {
this.play();
}
As you may have guessed, this is what happens when Flash waits around for the 2 seconds. The play() method simply tells the timeline to start playing again (see Figure 1).

(+) view larger
Figure 1: Pausing the Flash timeline