PDA

View Full Version : TIMER ??


udi
08-16-2001, 02:46 AM
how do i do a count down timer in flash ??

Jesse
08-17-2001, 04:11 AM
On a movie clip:
onClipEvent (load) {
wait = 5;
starTimer = true;
}
onClipEvent (enterFrame) {
if (starTimer) {
if (startTime == undefined) {
startTime = getTimer()/1000;
}
curTime = getTimer()/1000;
if ((curTime-startTime)>=wait) {
starTimer = false;
delete startTime;
// actions to do after time is up
trace ("bing!");
} else {
_root.timeRemaining = wait-(curTime-startTime);
}
}
}
To get it to start counting down, just set movieClipName.startTimer = true;

cinciem
09-25-2001, 06:27 PM
Hi,

I am trying the timer too. I would like to countdown from 2 minutes in a dynamic text box. I tried this code, and it is giving me very strange results. I think that I am not understanding the variables that need to be created vs the code inante in Flash.

Could you comment this code and help me out? What is curTime? Could that be my dynamic text box variable?

I am trying to fight my way through this, but help would be wonderful.

Strok
09-25-2001, 07:37 PM
wait = 5; ---- time to count
curTime -- current time
timeRemaining -- dynamic text box


find more scripts here:

http://www.actionscripts.org/actionscripts_library/cgi-bin/search.cgi?query=countdown&submit=SEARCH

cinciem
09-26-2001, 01:40 PM
Thanks for your help. I checked out the resources you recomended- and I am getting there I think.

My goal is to count backwards from 2 minutes. In the past I have cheated with an animation of numbers that is based on fps. This is my first timer try (obviously).

This code gives my too many decimal places and counts forward. Could someone help me place the int correctly so it displays only 2 numbers.

Also, any suggestions on counting backwards?

onClipEvent (load) {
wait = 120;
starTimer = true;
}
onClipEvent (enterFrame) {
if (starTimer) {
if (startTime == undefined) {
startTime = getTimer()/1000;
}
curTime = getTimer()/1000;
if ((curTime-startTime)>=wait) {
starTimer = false;
delete startTime;
// actions to do after time is up
trace ("bing!");
} else {
_root.timer.timeRemaining = wait-int((curTime-startTime)/1000);
}
}
}

thanks for taking the time to help me out.:)