Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create "elapsed" time clock w/ minutes/seconds/milliseconds

Status
Not open for further replies.

propshop

Technical User
Aug 16, 2002
9
US
I would like to add a timer (not a countdown) in my animation that starts from zero, has a format like 00:00:00 and goes until a certain frame then stops. ACTUAL/ACCURATE time elapsed isn't so important as the action of time passing. As long as it is close and relatively believeable.

Can anyone help?
-Julie
 
place a dynamic text box on stage with instance name theTime

add to first frame

Code:
seconds = 0;

function formatTime(time) {
var h = Math.floor(time/3600)<10 ? &quot;0&quot;+Math.floor(time/3600) :
Math.floor(time/3600);
var m = (Math.floor((time/60)%60)<10) ? &quot;0&quot;+Math.floor((time/60)%60) :
Math.floor((time/60)%60);
var s = ((time%60)<10) ? &quot;0&quot;+(time%60) : (time%60);
return h+&quot;:&quot;+m+&quot;:&quot;+s;
}

function clock() {
seconds ++;
theTime.text = formatTime(seconds);
}
theTimer = setInterval(clock, 1000);

then in the last frame

clearInterval(theTimer)
 
Can you give dynamic text an instance name in Flash 5? I don't seem to be able to figure it out....
 
no you cant...you have to use a variable name..give your textfield the variable name theTime and delete the .text from the above


looking over that again i see you want milliseconds in which case change the 1000 in the setinterval statement to 1
 
Thanks Bill - I'll give it a try. Also, if I'm putting this on a black background, how do I make sure the text is white?
 
however it is you set text color in 5. id asume through the properties panel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top