| Package | org.aswing.util |
| Class | public class Timer |
| Inheritance | Timer AbstractImpulser flash.events.EventDispatcher |
| Implements | Impulser |
Timer
as the trigger for drawing its frames.
Setting up a timer
involves creating a Timer object,
registering one or more action listeners on it,
and starting the timer using
the start method.
For example,
the following code creates and starts a timer
that fires an action event once per second
(as specified by the first argument to the Timer constructor).
The second argument to the Timer constructor
specifies a listener to receive the timer's action events.
var delay:Number = 1000; //milliseconds
var listener:Object = new Object();
listener.taskPerformer = function(e:Event) {
//...Perform a task...
}
var timer:Timer = new Timer(delay);
timer.addActionListener(listener.taskPerformer);
timer.start();
| Method | Defined by | ||
|---|---|---|---|
|
Timer(delay:uint, repeats:Boolean = true)
Construct Timer.
| Timer | ||
![]() |
addActionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds an action listener to the
AbstractImpulser
instance. | AbstractImpulser | |
![]() |
getDelay():uint
Returns the delay between firings of events.
| AbstractImpulser | |
![]() |
getInitialDelay():uint
Returns the
AbstractImpulser's initial delay. | AbstractImpulser | |
![]() |
isRepeats():Boolean
Returns
true (the default)
if the AbstractImpulser will send
an action event to its listeners multiple times. | AbstractImpulser | |
|
isRunning():Boolean
Returns
true if the Timer is running. | Timer | ||
![]() |
removeActionListener(listener:Function):void
Removes a action listener.
| AbstractImpulser | |
|
restart():void
Restarts the
Timer,
canceling any pending firings and causing
it to fire with its initial delay. | Timer | ||
![]() |
setDelay(delay:uint):void
Sets the
AbstractImpulser's delay between
fired events. | AbstractImpulser | |
![]() |
setInitialDelay(initialDelay:uint):void
Sets the
AbstractImpulser's initial delay,
which by default is the same as the between-event delay. | AbstractImpulser | |
![]() |
setRepeats(flag:Boolean):void
If
flag is false,
instructs the AbstractImpulser to send only once
action event to its listeners after a start. | AbstractImpulser | |
|
start():void
Starts the
Timer,
causing it to start sending action events
to its listeners. | Timer | ||
|
stop():void
Stops the
Timer,
causing it to stop sending action events
to its listeners. | Timer | ||
| Timer | () | constructor |
public function Timer(delay:uint, repeats:Boolean = true)Construct Timer.
Parametersdelay:uint |
|
repeats:Boolean (default = true) |
— when init delay <= 0 or delay == null
|
See also
| isRunning | () | method |
public override function isRunning():Boolean
Returns true if the Timer is running.
Boolean |
See also
| restart | () | method |
public override function restart():void
Restarts the Timer,
canceling any pending firings and causing
it to fire with its initial delay.
| start | () | method |
public override function start():void
Starts the Timer,
causing it to start sending action events
to its listeners.
See also
| stop | () | method |
public override function stop():void
Stops the Timer,
causing it to stop sending action events
to its listeners.
See also