|
||||||
|
||||||
Flash Tutorial - Delays, Timers & Stop Watches
Free Flash Tutorial
Delayed Action
Example
B: Download the Flash file Int 156b
In the Flash Movie that you will learn to build now there is a pre set delay and then an action will happen but this time it will not repeat but only happen once. In this instance the ActionScript will send a delayed message to the
Output Window.

A single message is displayed in the Output Window.
Delayed Action: The ActionScript
Add line 3 to the code in Frame 1 and change the time to 2 seconds (Bits in red):
function wait() { // a function called 'wait'
trace("The time is now !!"); // the action you want, in this case a trace.
clearInterval(myTimer); //stops the function being called again.
}
myTimer = setInterval(wait, 2000); // calls the function wait after 2 seconds
Delayed Action: Test the Movie
Test your movie: Control > Test Movie
You should see the following in the Output Window:
The time is now !!
After two seconds the message will appear in the Output Window once only.
That's about all there is to setting a delay or getting an action to repeat! The power of this code is what you place in the function, which could be anything.
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
34123 visitors to this page since April 06 |
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|