Documents > BPS V2 Script API
bps::Timer Class Reference

The Timer class provides repetitive and single-shot timers. More...

List of all members.

Signals

void timeout ()
 Signal emitted when the timer times out.

Public Member Functions

void start (Number aMillisecs)
 Starts or restarts the timer with a timeout interval of msec milliseconds.
void stop ()
 Stops the timer.
 Timer ()
 Constructor.

Properties

Boolean active
 True if the timer is running.
Number interval
 This property holds the timeout interval in milliseconds.
Boolean singleShot
 This property holds whether the timer is a single-shot timer.

Detailed Description

The Timer class provides repetitive and single-shot timers.

Example use of the Timer class:

 function hello()
 {
     print('hello!');
 }
 var timer = new bps.Timer;
 timer.singleShot = true;
 timer.timeout.connect(hello);
 timer.start();   

Member Function Documentation

void bps::Timer::start ( Number  aMillisecs)

Starts or restarts the timer with a timeout interval of msec milliseconds.

Starts or restarts the timer with the timeout specified in interval if no parameter is passed, or the time passed as parameter. If singleShot is true, the timer will be activated only once.

Parameters:
aMillisecsTimeout interval.

Property Documentation

Boolean bps::Timer::active [read]

True if the timer is running.

 

Number bps::Timer::interval [read, write]

This property holds the timeout interval in milliseconds.

The default value for this property is 0. A Timer with a timeout interval of 0 will time out as soon as all the events in the window system's event queue have been processed.

Boolean bps::Timer::singleShot [read, write]

This property holds whether the timer is a single-shot timer.

A single-shot timer fires only once, non-single-shot timers fire every interval milliseconds.