Developing Webs logo
Web DW-Main DW-Photoshop
Visit the message board for solutions or post a question Check out the Classes offered for free at Developing Webs Voice Chat submit a tutorial, resources, article, font for publication consideration and earn a one way link back to your site Get more specifics about the Developing Webs Voice chat room and its room members View the current news at Developing Webs alternative sites which are resources for your d3evelopment needs Join Developing Webs Chat Link to us on your web page to help support this resource! Check out Developing Webs At yahoo groups! Developing Webs Home Adobe Photoshop Tutorials Macromedia Flash Tutorials Jasc Paint Shop Pro Tutorials Adobe Illustrator Animation basics Some Basic PHP tutorials Perl Tutorials HTML Tutorials Cascading Style Sheets javascript Front Page Tutorials Macromedia Dream Weaver Tutorials dreamweaver Publishing your site, FTP, ChMod, Promotions
RSS Newsfeed
for your site
DW News
DW Forum
Right click on button and copy shortcut

Add to My Yahoo!

Remember to book mark this site!

Request a Tutorial

Counting Time in Seconds

This is the easiest way to break into the time loop for timing people on activities in flash. This tutorial uses a loop which increments time by 1 second every loop. The variable time occurs in the script, and as the variable for the dynamic text box, therefore we are asking to print out the variable as the movie progresses.

In this movie we will work on the main timeline. If you put this in a movie clip you will have a nice exportable movie clip for other movies.



1. Create a new movie.

2.Click anywhere on the movie stage and open your properties panel.. You will need to make sure you are set to a frame rate of 12 fps (frames per second) so the timing is correct in counting time. This means that your movie will progress at 12 frames each second. click ok.

3.  Insert new layer by right clicking on layer one and selectiong insert layer. Click on the name to activate the edit box and Name it Actions.
Rename Layer 1 to Counter.

4. Select your text tool and click on frame 1 of counter. Click on your stage to plant a text box. On the properties panel make sure it is totally open by clicking the small carrot in the lower right corner of the properties panel. Set the set box as follows:

  • dynamic text
  • Single line
  • variable = time

5. Resize your text box on the stage to the size you want your text to fill. On the character panel, select the size of font. On the paragraph select the orientation of the text. In this example I set it to center the text. (Any additional text must be in a separate text box as static text.)

6. Click on the layer counter frame 13 and hit F5 to extend out to that frame.

7. Insert a keyframe on the actions layer frame 2 by clicking in frame 2 of the actions layer and hitting the F6 key. Highlight frame 1 of the actions layer and Open your action panel.

8. Setting up a variable: Click + => actions => variables=>  set variable.


Type in the following:

  • variable name is Time
  • the value is 0
  • check expression box.


So the action in frame 1 looks like this: time = 0;

9. Click on frame 13 on the actions layer and hit F6 to insert keyframe. What we will do on frame thirteen is set an action that will increment the variable time by 1 every twelve frames.

On the actions panel click the right and arrow and select expert mode which allows up to type in any command that is not listed as we want it in the presets.

Type in the Following:  time ++;
This will increase time by a value of 1 each time this frame is played. (if you were starting with a high number and wanted to count down by one you might type in: time -- ;)

Check your syntax by clicking the right hand arrow on the actions panel and select Check syntax. When you see that you have typed it in correctly, return to normal mode by clicking the right arrow and select normal mode.

10. After you have added the increment on the 13th frame you will need to tell flash to replay the loop of 12 frames. While your still on frame 13 select + => basic actions => goto. Then select the frame number 2.

This sends the movie back to play frame number 2-13, or 12 frames before it increases time by a value of 1. Remember 12 frames is a second on a movie that is 12fps. 16 frames would be a second on a movie that is 16 fps.

Your resulting script on frame 13 should look like this:

gotoAndPlay (2)

And your movie timeline should look like this:

You might ask why we do not send the movie back to frame 1. This is because it would reset the value of time to 0, since frame 1 has the action script time=0; in it.

You should be able to count time now. If you build this movie in a movie clip, you have an automatic timer in seconds you can use in any movie.

"Building The Web Into a Nicer Place -- One Site At A Time"
Developing Webs Group Copyright © 2001-2023 All Rights Reserved
Privacy and Legal