How to set a timer?

Posted on 2005-03-17
Medium Priority
Last Modified: 2010-04-03
Hell flashexperts,

At frame 1 in want to start a timer.
at a certain point i my movie my movie will be directed
to for example frame 40. in that frame i would like to stop the timer
and display it on the screen.
for example :"" you're time was --minutes --sec.
how do i do that?

Kind regards
Question by:stevenvervliet
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 14

Expert Comment

ID: 13571914
frame 1:
_global.timed = getTimer();

frame 40:
temp = getTimer();
elapsed = temp - _global.timed;

Basically, on frame 1, the amount of time that has elapsed since the start of the movie is taken down into a global var. On frame 40, the temp var will check the time that has elapsed since the start of the movie, the the elapsed var will take down the diff between the 2 in miliseconds. I'm sure you can handle the rest of the process from here ;-)

LVL 39

Accepted Solution

blue-genie earned 200 total points
ID: 13572238
the only problem with using getTimer is that it is a readOnly value, and it keeps going, another way of doing it will be to use setInterval,

so in your first frame

function callback() {
      valuer = valuer+1;
valuer = 0;
id = setInterval(callback, 1000);

then in frame 40 you clear the interval (i.e tell it to stop) and show the result (using a trace here) you can just display valuer in a textbox or whatever, its a variable.

trace("final time is: " + valuer);
stop();//if required


Author Comment

ID: 13685734
Thank you BLU, it works JUST fine....

Kind regards
Antwerp City
LVL 39

Expert Comment

ID: 13695398
np :)

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question