JSUTILS.Timer Class
The Timer object wraps the window.setInterval() method to provide an as3-like Timer interface.
Constructor
JSUTILS.Timer
-
delay
-
repeatCount
Parameters:
-
delay
NumberThe delay (ms) interval between ticks
-
repeatCount
NumberThe number of number of ticks. A value of zero will set the timer to repeat forever. Default = 0
Item Index
Properties
Events
Methods
addEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
dispatchEvent
-
type
-
optionalParams
Parameters:
-
type
EventThe Event object.
-
optionalParams
ObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
hasEventListener
-
type
Parameters:
-
type
StringThe event type return {boolean} True is listener exists for this type, false if not.
onTick
()
private
removeEventListener
-
type
-
listener
Parameters:
-
type
StringThe event type
-
listener
FunctionThe function to be called when the event is fired
reset
()
Stop the timer and reset the count to zero.
start
()
Start the timer.
stop
()
Stop the timer.
Properties
currentCount
Number
[read-only] Returns the current count (number of ticks since timer started).
delay
Number
The delay interval in milliseconds.
repeatCount
Number
The repeat count in milliseconds.
running
Number
[read-only] Returns true if the timer is running.
Events
timerComplete
JSUTILS.TimerEvent.TIMER_COMPLETE
The timerComplete event is dispatched when the repeatCount value
Event Payload:
-
target
JSUTILS.TimerA reference to the Timer object.
timerTick
JSUTILS.TimerEvent.TIMER
The timerTick event is dispatched at the rate specified by the delay interval.
Event Payload:
-
target
JSUTILS.TimerA reference to the Timer object.