How to use a Timer in Actionscript 3

It is really easy to create a Timer in Actionscript 3.

Instantiate the Timer Class and pass a time in millions of 1000 to it to work in seconds.

var myTimer:Timer = new Timer(1000);

Setup an event listener to call a function.

myTimer.addEventListener("timer", myTimerEventHandler);

Start the Timer.

myTimer.start();

Start the Timer.

function myTimerEventHandler(event:TimerEvent):void {
        trace(myTimer.currentCount+" seconds have passed.");
}

So altogether we have this.

var myTimer:Timer = new Timer(1000);
myTimer.addEventListener("timer", myTimerEventHandler);
myTimer.start();
function myTimerEventHandler(event:TimerEvent):void {
        trace(myTimer.currentCount+" seconds have passed.");
}

Now you know how to use a Timer in Actionscript 3.


Share This Article

Related Posts

Comments

There are no comments on this entry.

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional

Latest Domains

1. weebly.com
(1 day ago)
2. whpromotions.co.uk
(1 day ago)
3. adsl24.co.uk
(1 day ago)
4. youryoungmodels.net
(1 day ago)
5. enom.com
(1 day ago)
6. dynect.net
(1 day ago)
7. websitewelcome.com
(1 day ago)
8. hostgator.com
(1 day ago)
9. uploading.com
(2 days ago)
10. soccernetghana.com
(2 days ago)

Services

PHP MySQL Apache Flash Air Java C++ Python