Show:

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 Number

    The delay (ms) interval between ticks

  • repeatCount Number

    The number of number of ticks. A value of zero will set the timer to repeat forever. Default = 0

Methods

addEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The function to be called when the event is fired

dispatchEvent

(
  • type
  • optionalParams
)

Parameters:

  • type Event

    The Event object.

  • optionalParams Object

    Optional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.

hasEventListener

(
  • type
)

Parameters:

  • type String

    The event type return {boolean} True is listener exists for this type, false if not.

onTick

() private

removeEventListener

(
  • type
  • listener
)

Parameters:

  • type String

    The event type

  • listener Function

    The 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:

timerTick

JSUTILS.TimerEvent.TIMER

The timerTick event is dispatched at the rate specified by the delay interval.

Event Payload: