Handles calling of a delegate after a specified number of milliseconds.
LzTimer is used to invoke functionality after a specific amount of time. By using a delegate to refer to a particular method, and then by adding a timer to that delegate, the developer can control the timing of the method's start. Use LzTimer to tweak sequence and timing of visual animations, delay the effects of user events, or implement user experiences with expiration features.
It should be noted that the time passed to the LzTimer service describes the time before which the delegate may not run -- it is not guaranteed that the delegate will run at that time. Depending on application needs and client performance, the specified delegate may be invoked at any time after the amount of time specified.
The following example displays some text when a button is clicked, and uses LzTimer to fade the text away after three seconds.
<canvas height="50" >
<button text="Show then Fade" onclick="canvas.showText()" />
<text name="myText" opacity="0.0" bgcolor="#CCCCCC">The Invisible Man</text>
<simplelayout axis="y" spacing="10" />
<method name="showText">
this.myText.setAttribute( "opacity", 1.0 );
this.fadeDelegate = new LzDelegate( this, "fadeText" );
LzTimer.addTimer( this.fadeDelegate, 3000 );
</method>
<method name="fadeText">
this.myText.animate( "opacity", 0.0, 1000 );
</method>
</canvas>
| Attributes | |||||
| Name | Usage | Type (Tag) | Type (JS) | Default | Category |
| timerList | JS only | Array of LzTimer | readonly | ||
| The array of active timers | |||||
|
|
|||||
| addTimer() | ||
| LzTimer.addTimer(d, milisecs) | ||
|
Adds a timer. NB: The timer guarantees that the delegate will not be called before the number of miliseconds specified here, but cannot guarantee that it will be called at exactly that time. |
||
| Parameters | ||
| Name | Type | Desc |
| d | LzDelegate | The delegate to call when the timer expires |
| milisecs | Number | The number of milisecs to wait before calling the delegate. |
|
|
||
| removeTimer() | ||
| LzTimer.removeTimer(d) | ||
|
Removes the first timer that calls the given delegate from the timerlist. |
||
| Parameters | ||
| Name | Type | Desc |
| d | LzDelegate | The delegate called by the timer to be removed. If there are multiple timerList entries that call delegate d, removes the first in the order received. |
|
|
||
| resetTimer() | ||
| LzTimer.resetTimer(d, milisecs) | ||
|
Resets the timer for the given delegate to the new amount of time. If the delegate is not found, a new timer is created. |
||
| Parameters | ||
| Name | Type | Desc |
| d | LzDelegate | The delegate called by the timer to be reset. If there are multiple timers for this delegate, the first one is reset. If this delegate is not found in the timer list, a new timer event is created for it. |
| milisecs | The number of miliseconds to wait before calling the timer. | |
|
|
||
Copyright © 2002-2005 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.