Timer class updated

Friday 14 May 2004  –  Filed under: Flash  –  No Comments

I’ve updated my previously posted Timer class. It has been extended with (a slightly modified version of) Design Nation’s Callback class to allow for executing a callback function when the timer is ready. I’ve also made some changes to the events broadcasted by the Timer class.

To use this class, simply download the source files and place both classes (Timer.as and Callback.as) in the correct package folder (mine is “com/mdv/”) in your Flash MX 2004 classpath. The download includes some documentation, which you can also read online.

The code below creates a timer that runs 3 loops of 2 seconds each:

import com.mdv.Timer;
var myTimer:Timer = new Timer(2000, 3);

This sample code uses the new callback extension:

import com.mdv.Timer;
myTimer:Timer = new Timer(1000, 2, { context:this, method:"onTimerReady" } );
myTimer.start();

Don’t forget the online sample.

« previously: Hello invaders! next: Macromedia’s ASDoc »


Leave a Reply