|
||||||
|
||||||
Flash Tutorial - Delays, Timers & Stop Watches
Free Flash Tutorial
Creating a Timer
In this example you will learn to make a Flash Movie with a Timer. In this case I have made a Digital Display for the timer which shows you the time lapsed in seconds. As the display is only in seconds when the timer gets to 60 it keeps going up in whole seconds to 61, 62 etc. In the next example I will show you how to create a timer that displays minutes and seconds.
Example
C: Download the Flash file Int 156c
Timer that counts in seconds.
Timer: The Stage
There is some standard static text on stage but what is more important is a Dynamic text box called: mySeconds

The settings for the Dynamic Text box.
Variable Name: In the Property inspector the Dynamic text box has a Variable name (Var:) not an Instance name:
Variable name: mySeconds
This is important. If you do it the other way around the Flash files described in this tutorial will not work !!
Zero: The Dynamic text box has a zero typed into it:
Variable is set to zero.
Zero is the starting point for the timer. If you did not do this it would be blank until the delay of 1 second had passed and only then display the number 1.
Character Options: Also note the Character Options are set to Numerals only:
This setting makes the Movie much smaller. You can access the Charter Options by clicking on the Embed button at the right end of the Property inspector.
Timer: The ActionScript
Place the following ActionScript in Frame 1:
function wait() {
mySeconds++; //adds 1 to the text box: mySeconds
}
myTimer = setInterval(wait, 1000);
It is so simple it needs no explanation, I hope?
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
34121 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.
|