Flash Training: Repeat Action

Home Food Mates • Members Tutorials Forum Buy Templates Contact Us 

 


Flash Tutorials

   

Flash Tutorial - Delays, Timers & Stop Watches

 

Free Flash Tutorial


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

 

Repeat Action

Example A: Download the Flash file  Int 156a

This is a very simple example of getting something to repeat. It sends a message repeatedly (every second) to the Output Window. It would be very easy to adjust the ActionScript so that Flash would repeat some any other action. This repeat action is set to go at every second, you could adjust this to a delay of just a fraction of a second or a prolonged delay of several minutes or more.


Repeating message in the Output Window.

In practical terms this is not much use but it demonstrates the simplicity of the code.

Repeat Action: The ActionScript

Open a new Flash Movie and place the following code in frame 1:

function wait() {                // a function called 'wait'
    trace("The time is now !!"); // the action you want, in this case a trace.
}
myTimer = setInterval(wait, 1000); // calls the function after 1 second


Repeat Action
: Test the Movie

Test your movie: Control > Test Movie

You should see the following in the Output Window:

The time is now !!
The time is now !!
The time is now !!

etc...

Once the setInterval has started it just keeps on going. While you are testing the movie try and close the Output Window. You will find that it just jumps right back at you.

You can create any action at all by replacing line 2: trace("The time is now !!"); with any action that you may want.

If you want a different delay change the 1000 (1000 milliseconds) to a different number. 2000 would be 2 seconds.

         

Step 1    <<   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

34119 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.