lz.TimerService
Handles calling of a delegate after a specified number
of milliseconds.
JavaScript: lz.TimerService
lz.Timer
is the single instance of the class
lz.TimerService
.
lz.Timer is used to invoke functionality after a specific
amount of time. By using a <handler> 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 lz.Timer 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 lz.Timer 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 lz.Timer to fade the text away after three
seconds.
Example 24. Using lz.Timer to invoke method
<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
">
myText.setAttribute( "opacity", 1.0 );
lz.Timer.addTimer( new LzDelegate( this, "fadeText" ), 3000 );
</method
>
<method
name
="fadeText
" args
="ignore=null
">
myText.animate( "opacity", 0.0, 1000 );
</method
>
</canvas
>
Methods
-
-
lz.TimerService.addTimer(d : lz.handler, millisecs : Number);
Adds a timer. Note: The timer guarantees that the delegate will
not be called before the number of milliseconds specified here,
but cannot guarantee that it will be called at exactly that time.
-
-
lz.TimerService.countTimers(d : lz.handler);
Returns the number of timers registered for a delegate
NOTE: Only available in debug mode.
-
-
lz.TimerService.removeTimer(d : lz.handler);
Removes the first timer that calls the given delegate from the
timerlist.
-
-
lz.TimerService.resetTimer(d : lz.handler, millisecs);
Resets the timer for the given delegate to the new amount of
time. If a timer for the delegate is not found, a new timer is
created.