Link Search Menu Expand Document

DisplayObject.SetTimer Method

Explanation Raises a Timer event at sec intervals. One timer can be set for one object. The timer resolution is 0.1 seconds.

If you set a timer, the event will occur repeatedly at specified intervals. Call the RemoveTimer method to remove the set timer.

If the sec interval is shorter than the time required to process the OnTimer event handler, Timer events may accumulate in the event queue and become inoperable. Pay close attention to the specified interval of sec.

Also, if you write the RemoveTimer method in the Timer event with the expectation that it will be executed only once, if you specify a very short sec interval, the next Timer event will occur before the RemoveTimer method in the Timer event is executed. Be sure to specify oneshot as $ TRUE for a one-time execution.

Calling the SetTimer method is invalid for Doc objects and their child objects from Ver.4.0.5.
No error will occur, but the Timer event will not occur.
From Ver.5.0.0, the resolution of the timer has been expanded from 0.1 seconds to 0.01 seconds.

Call format obj.SetTimer( sec [, oneshot ] )
Return value None
Arguments Number sec Specifies the timer event issuance interval in seconds.
boolean oneshot Specifying $ TRUE raises the Timer event only once. In this case, you don't need to call the RemoveTimer method.
The default is $ FALSE.

Added since Ver.5.0.0

Not supported in Mobile

Exception None
Example of use
SetTimer(2.5);
var count = 0;
Function OnTimer(e) {
    count++;
    if (count >= 5) {
        RemoveTimer();
    }
    print(sysdate(), "\n");
}
    
Related item RemoveTimer method
Timer event