Learn Flash: Delay

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Flash Tutorial - Delays, Timers & Stop Watches

 

Free Flash Tutorial


Step 2    <<   Previous      Intro   1   2   3   4   5   6     Next   >>       >>   Webwasp Mates

 

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.

         

Step 2    <<   Previous      Intro   1   2   3   4   5   6     Next   >>       >>   Webwasp Mates


Webwasp Community: Webwasp Mates & Dates

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

 Top of Page Home Food Mates Members Tutorials Forum Buy Templates Contact Us 
 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.