Flash AS3 – Timer Class

Here is a quick timer code for you to use within your project. I know it may seem simple but its usually the simple things that causes most headaches. So this is for those folks that constantly need reminders.

[as]// We need to import the utils package
import flash.utils.*;

// Create a new Timer object with a delay of 1000 ms
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(“timer”, timedFunction);

// Start the timer
myTimer.start();

// Function will be called every second
function timedFunction(eventArgs:TimerEvent)
{
trace(“Timer fired ” + myTimer.currentCount + ” times.”);
}[/as]

Check out the AS 3 docs to see all of the available properties and methods of this great new class.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s