
If you wish to keep track of how many times the Timer has been counting, then you can use the currentCount property of the Timer class. So now, if you test the movie, you will see the word hello come out in the output window every 1 second. MyTimer.addEventListener(TimerEvent.TIMER, sayHello) function sayHello(e:TimerEvent):void

So let's go ahead and create a TimerEvent.TIMER event handler that will tell Flash to display the word hello in the output window every time the Timer makes a count.
#ADOBE FLASH ACTIONSCRIPT 3.0 STOP FUNCTION NOT WORKING MOVIE#
This event is useful if you'd like your Flash movie to do something repeatedly at a constant interval. So for example, if you have a Timer object that has a 1 second delay, then TimerEvent.TIMER will get dispatched every 1 second. This event gets dispatched every time the Timer object makes a count. Let's first take a look at the TimerEvent.TIMER event. In order to tell Flash to respond and do something, then we'll need to create AS3 Timer event handlers so that our Flash movie will know what to do when certain Timer associated events get dispatched. If you test your movie now, the Flash movie will launch, but you won't see anything happen. Use the start() method of the Timer class in order to tell the Timer object to start. It will usually be off by a few milliseconds, but in many cases, it's barely noticeable. NOTE: The delay is not always 100% accurate. A delay of one second has been specified. This creates a new Timer object named myTimer. The delay parameter is required, while the repeatCount is optional. So for example, if you specify a repeatCount of 5, then the Timer will count 5 times and then stop. If you specify a positive nonzero value, then the timer runs at that specified number of times and then stops.

If you don't specify a repeatCount or if you specify zero, the timer repeats indefinitely. The repeatCount specifies the number of repetitions the Timer will make. The second parameter is for the repeatCount. The Timer ActionScript 3 constructor accepts 2 parameters.

So now let's go ahead and create a new AS3 Timer object. You can specify a delay as short as 20 milliseconds, but anything lower than that is not recommended and may cause problems. If there is a delay of 5000 milliseconds, then the Timer counts every 5 seconds. For example, if there is a delay of 1000 milliseconds, then the Timer object will count at 1 second intervals. NOTE: For those of you coming from AS2 and have been using the setInterval() function - there is also an AS3 setInterval() function, but the AS3 Timer class is a good alternative to using setInterval().Ī Timer object has the ability to count at a specific interval, which can be set using what is called the delay.
