RSS
Home General How to use a Timer in Actionscript 3
formats

How to use a Timer in Actionscript 3

Published on June 10, 2010 by in General

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 on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© Copyright © 2016 · Web Development London UK · All rights reserved
By using the site and/or making use of any of our services you agree to our Terms and Conditions