Packageorg.aswing.util
Classpublic class Timer
InheritanceTimer Inheritance AbstractImpulser Inheritance flash.events.EventDispatcher
ImplementsImpulser

Fires one or more action events after a specified delay. For example, an animation object can use a 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();
 



Protected Properties
 PropertyDefined by
 Inheriteddelay : uint
AbstractImpulser
 InheritedinitialDelay : int
AbstractImpulser
 InheritedisInitalFire : Boolean
AbstractImpulser
 Inheritedrepeats : Boolean
AbstractImpulser
Public Methods
 MethodDefined by
  
Timer(delay:uint, repeats:Boolean = true)
Construct Timer.
Timer
 Inherited
addActionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds an action listener to the AbstractImpulser instance.
AbstractImpulser
 Inherited
getDelay():uint
Returns the delay between firings of events.
AbstractImpulser
 Inherited
Returns the AbstractImpulser's initial delay.
AbstractImpulser
 Inherited
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
 Inherited
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
 Inherited
setDelay(delay:uint):void
Sets the AbstractImpulser's delay between fired events.
AbstractImpulser
 Inherited
setInitialDelay(initialDelay:uint):void
Sets the AbstractImpulser's initial delay, which by default is the same as the between-event delay.
AbstractImpulser
 Inherited
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
Constructor detail
Timer()constructor
public function Timer(delay:uint, repeats:Boolean = true)

Construct Timer.

Parameters
delay:uint
 
repeats:Boolean (default = true)

Throws
— when init delay <= 0 or delay == null

See also

Method detail
isRunning()method
public override function isRunning():Boolean

Returns true if the Timer is running.

Returns
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