Developing Webs logo
Google
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
Calendar
DW Forum
Right click on button and copy shortcut

Add to My Yahoo!

Reminder
Remember to book mark this site!



Request a Tutorial

Counting Time using getTimer() Function

1. Create a static text box with the words time: in black on your stage.

2. Created a dynamic text box next to it with black text, centered, and with var = time

3. Rename your layer to text. Lock it. Insert a layer and rename it actions.

4. Click In frame 1 of your actions layer. Open your actions palette. On the toolbox on the left, select actions=> Variables=> Set Variables.

4. In the actions parameters set the variable as time, the same as the var in the dynamic text box. Click in the value field and find in the action toolbox functions=> getTimer. Check expression. GetTimer script will display the time in 1000ths of a second since the movie started.

5. Test movie by clicking Control=> Test Movie. Here you will only see one value for time elapsed. This is because your movie is only one frame and a single frame movie does not loop. We need to extend the timeline so the movie will loop and revisit the set variable script to update your time.

6. Clicked on top of the layers palette right on the playhead and hit F5 to extend your layers out to frame 2.

7. Test your movie. Now your dynamic text box will show thousandths of seconds. This is why it updates so fast. We will need to change this time to seconds in the next step.

8. Click in frame 1 of the actions layer and open your actions panel again. Where the value says GetTimer(), add /1000 to divide by 1000, so that we convert the value to the unit of seconds.

9. Test your movie. Your dynamic test box will display the time in seconds, and include a decimal after it. If you want whole numbers you will need to round this value in the next step.

10. We have three methods for rounding. Ceil will round up, floor will round down, and round will round up if over .5 and down if under .5. In this case we want the time to register 1 after the movie has been open for 1 second so we need to round using floor, or down.

In your value field, copy the statement getTimer()/1000 by highlighting, right clicking and selecting copy. Then delete the script in the value field. Open your action script tool box and select objects=> core=> math=> methods=> Floor so the script ends up in the value box. This will round down whatever is in the parenthesis. Click inside the parentheses in the value box, and right click and paste the getTimer()/1000 script so that the resulting script is

time = Math.floor(getTimer()/1000);

Test your movie.



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