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.

Static variables


The global timer manager that handles global timers

Available since





Creates a new timer.


@:value(false)active:Bool = false

Pauses or checks the pause state of the timer.

read onlyelapsedLoops:Int

Read-only: how many loops that have elapsed since the timer was started.

read onlyelapsedTime:Float

Read-only: The amount of milliseconds that have elapsed since the timer was started

@:value(false)finished:Bool = false

Check to see if the timer is finished.

@:value(0)loops:Int = 0

How many loops the timer was set for. 0 means "looping forever".

read onlyloopsLeft:Int

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


The manager to which this timer belongs

Available since



read onlyprogress:Float

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

@:value(0)time:Float = 0

How much time the timer was set for.

read onlytimeLeft:Float

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

onComplete:FlxTimer ‑> Void

Function that gets called when timer completes. Callback should be formed "onTimer(Timer:FlxTimer);"



Stops the timer and removes it from the timer manager.


Clean up memory.

@:value({ NewTime : -1 })reset(NewTime:Float = -1):FlxTimer

Restart the timer using the new duration



The duration of this timer in seconds.

@:value({ Loops : 1, Time : 1 })start(Time:Float = 1, ?OnComplete:FlxTimer ‑> Void, Loops:Int = 1):FlxTimer

Starts the timer and adds the timer to the timer manager.



How many seconds it takes for the timer to go off. If 0 then timer will fire OnComplete callback only once at the first call of update method (which means that Loops argument will be ignored).


Optional, triggered whenever the time runs out, once for each loop. Callback should be formed "onTimer(Timer:FlxTimer);"


How many times the timer should go off. 0 means "looping forever".


A reference to itself (handy for chaining or whatever).


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 cancel(). However, callbacks are called AFTER cancel() is called.