How to use a Timer in Actionscript 3

0 min read 91 words

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.

Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags

Recent Posts