View Full Version : Countdown clock/timer
72chip
01-22-2003, 01:29 PM
Hi all,
I don't know how simple this is, but I'm definitely a "newbie," so here goes:
I'm trying to make a countdown clock timer that would start at say, 30 minutes and countdown to zero. I need to actually show the clock running in Flash, not just have it be something that runs in the background. I've been digging through the library and forums and just can't get it. Any help (written in the simplest terminology, please) would be much appreciated.
Cheers!
binkyboo
01-22-2003, 06:23 PM
f5 version compliments of tg
Creat a blank movie clip and past this code:
onClipEvent(load){
var beginCount=60;
var done=false;
}
onClipEvent(enterFrame){
if(!done){
_root.time=Math.ceil(beginCount-getTimer()/(1000*60));
if(_root.time<=0){
done=true;
_root.time=0;
}
}
}
Create a dynamic text box with a var name of time.
72chip
01-24-2003, 01:57 PM
Hmm.
Ok. I did that. But I only get a static number "60" that shows up where the dynamic text box is. I am using MX. Could that be the issue?
Thanks for the help. I really need to study up my ActionScript, I think.
Cheers.
binkyboo
01-24-2003, 02:13 PM
Did ya give it a minute?! It's counting down from 60 minutes.
72chip
01-24-2003, 02:18 PM
<inHomerSimpsonVox> DOH! </inHomerSimpsonVox>
No, I didn't! Excellent!
I think I'm going to want to see seconds, too. But I should be able to figure that out now. Thanks, much!
binkyboo
01-24-2003, 02:22 PM
lol
Been there done that!:)
friz2002
01-24-2003, 03:42 PM
Hi,
I changed the code a bit because I work in MX and I also wanted it to count seconds.
_root.onLoad = function(){
beginCount=60;
done=false;
}
_root.onEnterFrame = function(){
if(!done){
_root.time=Math.ceil(beginCount-getTimer()/(1000));
if(_root.time<=0){
done=true;
_root.time=0;
}
}
}
How do I change the code if I wanted the counter to start the countdown after a button is pressed??
72chip
01-27-2003, 07:14 PM
Yeah, that works nicely. NOW...I need to have it loop 30 times to correspond with a 30 minute countdown.
Right now, it counts down once and stops at zero. I need to repeat that 30 times to match my 30 minute countdown which I have going in another dynamic text box right next to it.
Any ideas? I'm assuming a loop command, but I haven't tried it yet.
By the way, the new "ActionScript for Flash MX: The Definitive Guide, Second Edition" is VERY NICE. I highly recommend!
Cheers.
amcquade
07-22-2003, 05:23 PM
Did you find out how to change the code so that the counter starts the countdown after a button is pressed?
i have the same problem.
Thx.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.