AWT. Timer

This class provides a timer that will launch a function at specific intervals

Constructor

new Timer(actionPerformed, interval, enabledopt)

Timer constructor

Parameters:
NameTypeAttributesDefaultDescription
actionPerformedfunction

The function to be triggered when the timer is enabled.

intervalnumber

The interval between action calls, specified in milliseconds.

enabledboolean<optional>
false

Flag to indicate if the timer will be initially enabled.

Members

interval :number

The timer interval, in milliseconds

Type:
  • number

repeats :boolean

When true, the timer should repeat until stop is called

Type:
  • boolean

ticks :number

The ticks counter

Type:
  • number

timer :object

The object returned by window.setInterval

Type:
  • object

Methods

actionPerformed(_thisTimer)

Here is where subclasses must define the function to be performed when this timer ticks.

Parameters:
NameTypeDescription
_thisTimermodule:AWT.Timer

isRunning() → {boolean}

Checks if this timer is running

Returns:
Type: 
boolean

processTimer(_event)

This is the method called by window.setInterval

Parameters:
NameTypeDescription
_eventexternal:Event

setEnabled(enabled, retainCounteropt)

Enables or disables this timer

Parameters:
NameTypeAttributesDefaultDescription
enabledboolean

Indicates if the timer should be enabled or disabled

retainCounterboolean<optional>
false

When true, the ticks counter will not be cleared

start(retainCounteropt)

Starts this timer

Parameters:
NameTypeAttributesDefaultDescription
retainCounterboolean<optional>
false

When true, the ticks counter will not be cleared

stop(retainCounteropt)

Stops this timer

Parameters:
NameTypeAttributesDefaultDescription
retainCounterboolean<optional>
false

When true, the ticks counter will not be cleared