Packageorg.flixel
Classpublic class FlxTimer
InheritanceFlxTimer Inheritance Object

A simple timer class, leveraging the new plugins system. Can be used with callbacks or by polling the finished flag. Not intended to be added to a game state or group; the timer manager is responsible for actually calling update(), not the user.



Public Properties
 PropertyDefined By
  finished : Boolean
Check to see if the timer is finished.
FlxTimer
  loops : uint
How many loops the timer was set for.
FlxTimer
  loopsLeft : int
[read-only] Read-only: check how many loops are left on the timer.
FlxTimer
  manager : TimerManager
[static] [read-only]
FlxTimer
  paused : Boolean
Pauses or checks the pause state of the timer.
FlxTimer
  progress : Number
[read-only] Read-only: how far along the timer is, on a scale of 0.0 to 1.0.
FlxTimer
  time : Number
How much time the timer was set for.
FlxTimer
  timeLeft : Number
[read-only] Read-only: check how much time is left on the timer.
FlxTimer
Protected Properties
 PropertyDefined By
  _callback : Function
Internal tracker for the time's-up callback function.
FlxTimer
  _loopsCounter : uint
Internal tracker for the loops counting up.
FlxTimer
  _timeCounter : Number
Internal tracker for the actual timer counting up.
FlxTimer
Public Methods
 MethodDefined By
  
Instantiate the timer.
FlxTimer
  
destroy():void
Clean up memory.
FlxTimer
  
start(Time:Number = 1, Loops:uint = 1, Callback:Function = null):FlxTimer
Starts or resumes the timer.
FlxTimer
  
stop():void
Stops the timer and removes it from the timer manager.
FlxTimer
  
update():void
Called by the timer manager plugin to update the timer.
FlxTimer
Property Detail
_callbackproperty
protected var _callback:Function

Internal tracker for the time's-up callback function. Callback should be formed "onTimer(Timer:FlxTimer);"

_loopsCounterproperty 
protected var _loopsCounter:uint

Internal tracker for the loops counting up.

_timeCounterproperty 
protected var _timeCounter:Number

Internal tracker for the actual timer counting up.

finishedproperty 
public var finished:Boolean

Check to see if the timer is finished.

loopsproperty 
public var loops:uint

How many loops the timer was set for.

loopsLeftproperty 
loopsLeft:int  [read-only]

Read-only: check how many loops are left on the timer.


Implementation
    public function get loopsLeft():int
managerproperty 
manager:TimerManager  [read-only]


Implementation
    public static function get manager():TimerManager
pausedproperty 
public var paused:Boolean

Pauses or checks the pause state of the timer.

progressproperty 
progress:Number  [read-only]

Read-only: how far along the timer is, on a scale of 0.0 to 1.0.


Implementation
    public function get progress():Number
timeproperty 
public var time:Number

How much time the timer was set for.

timeLeftproperty 
timeLeft:Number  [read-only]

Read-only: check how much time is left on the timer.


Implementation
    public function get timeLeft():Number
Constructor Detail
FlxTimer()Constructor
public function FlxTimer()

Instantiate the timer. Does not set or start the timer.

Method Detail
destroy()method
public function destroy():void

Clean up memory.

start()method 
public function start(Time:Number = 1, Loops:uint = 1, Callback:Function = null):FlxTimer

Starts or resumes the timer. If this timer was paused, then all the parameters are ignored, and the timer is resumed. Adds the timer to the timer manager.

Parameters

Time:Number (default = 1) — How many seconds it takes for the timer to go off.
 
Loops:uint (default = 1) — How many times the timer should go off. Default is 1, or "just count down once."
 
Callback:Function (default = null) — Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);"

Returns
FlxTimer — A reference to itself (handy for chaining or whatever).
stop()method 
public function stop():void

Stops the timer and removes it from the timer manager.

update()method 
public function update():void

Called by the timer manager plugin to update the timer. If time runs out, the loop counter is advanced, the timer reset, and the callback called if it exists. If the timer runs out of loops, then the timer calls stop(). However, callbacks are called AFTER stop() is called.