Timer

Kind of class:class
Inherits from:EventDispatcher < CoreObject
Implements:
Known subclasses:
Version:04/09/07
Author:Aaron Clinger
Classpath:org.casaframework.time.Timer
File last modified:Sunday, 19 August 2007, 13:43:33
Timer is used for executing code at a specific callback frequency.
Example:
function onFire(sender:Timer, fires:Number):Void {
    trace("onFire has been called " + fires + " times.");
}

var myTimer:Timer = new Timer(1000, 3);
this.myTimer.addEventObserver(this, Timer.EVENT_FIRE, "onFire");
this.myTimer.start();
Events broadcast to listeners:
onStart = function (sender:Timer) {}
onStop = function (sender:Timer) {}
onFire = function (sender:Timer, fires:Number) {}
onComplete = function (sender:Timer, fires:Number) {}

Constructor

Timer

function Timer (delay:Number, reps:Number)
Defines the Timer object that dispatches an event at a specific frequency.
Parameters:
delay:
The time in milliseconds between calls.
reps :
The amount of repetitions.

Class properties

EVENT_COMPLETE

static EVENT_COMPLETE:String = 'onComplete'(read,write)

EVENT_FIRE

static EVENT_FIRE:String = 'onFire'(read,write)

EVENT_START

static EVENT_START:String = 'onStart'(read,write)

EVENT_STOP

static EVENT_STOP:String = 'onStop'(read,write)

Instance methods

changeDelay

function changeDelay (delay:Number) : Void
Changes the time between repetitions. Does NOT reset reps/fires.
Parameters:
delay:
The time in milliseconds between calls.

destroy

function destroy () : Void
Removes any internal variables, intervals, enter frames, internal MovieClips and event observers to allow the object to be garbage collected.

Always call destroy() before deleting last object pointer.
#

getDelay

function getDelay () : Number
Returns:
Returns the time between repetitions.

getFires

function getFires () : Number
Returns the number of fires.
Returns:
The number of elapsed fires.

isFiring

function isFiring () : Boolean
Determines in the timer is running.
Returns:
Returns true if Timer instance is running/firing; otherwise false.

start

function start () : Void
Starts or restarts the timer. Resets reps/fires to 0.
Events broadcast to listeners:
onStart = function (sender:Timer) {}

stop

function stop () : Void
Stops the timer.
Events broadcast to listeners:
onStop = function (sender:Timer) {}