Lingo Dictionary > D-F > delay |
![]() ![]() ![]() |
delay
Syntax
delay
numberOfTicks
Description
Command; pauses the playback head for a given amount of time. The integer expression numberOfTicks
specifies the number of ticks to wait, where each tick is 1/60 of a second. The only mouse and keyboard activity possible during this time is stopping the movie by pressing Control+Alt+period (Windows) or Command+period (Macintosh). Because it increases the time of individual frames, the delay
command is useful for controlling the playback rate of a sequence of frames.
The delay
command can be applied only when the playback head is moving. However, when delay
is in effect, handlers still run: only the playback head halts, not script execution. Place scripts that use the delay
command in either an on enterFrame
or on exitFrame
handler.
To mimic the behavior of a halt in a handler when the playback head is not moving, use the startTimer
command or assign the current value of timer
to a variable and wait for the specified amount of time to pass before exiting the frame.
Example
This handler delays the movie for 2 seconds when the playback head exits the current frame:
on exitFrame delay 2 * 60 end
Example
This handler, which can be placed in a frame script, delays the movie a random number of ticks:
on keyDown if the key = RETURN then delay random(180) end
Example
The first of these handlers sets a timer when the playback head leaves a frame. The second handler, assigned to the next frame, loops in the frame until the specified amount of time passes:
--script for first frame on exitFrame global gTimer set gTimer = the ticks end --script for second frame on exitFrame global gTimer if the ticks < gTimer + (10 * 60) then go to the frame end if end
See also
![]() ![]() ![]() |