View Full Version : How to create a simple countdown with pause!
cookie
March 2nd, 2003, 08:22 AM
I've found numerous resources about getTimer() and stuff but I can't get a grip on the function. I want to create a very simple countdown timer where the total time is 10min and when you press a button it starts counting down and if you press another button it pauses and if you click again resumes the countdown! Furthermore if not too complicated I want to show the seconds as well, for example 9min 40sec etc.
AS knowers help me out, please! :P
kode
March 2nd, 2003, 09:14 AM
here ya go ;)
cookie
March 2nd, 2003, 09:21 AM
Appreciate it kax! There is a wierd thing with the timer! :( When you press start it adds 59sec and then counts down! Also when it changes from 9:00 to 8:59 it first does 9:00->9:59->8:59!
Did you see the same?
:)
kode
March 2nd, 2003, 09:25 AM
what ?? i didn't see that .. i'll download the file i always delete the files after uploading them :P and check it out :)
kode
March 2nd, 2003, 09:30 AM
:P
countdown = function () {
ss > 0 ? ss -- : clearInterval(countdowni);
s = ss%60;
s < 10 ? s = "0"+s : null;
s == 59 ? m -- : null;
countdownBox.text = m+":"+s;
}
sorry :-\ .. just replace the function and it should work fine now =)
cookie
March 2nd, 2003, 09:31 AM
np :P
kode
March 2nd, 2003, 09:37 AM
Originally posted by cookie
np :P
np ? i should say np !!
you should say thanks !! :hair:
:P j/k ;)
cookie
March 2nd, 2003, 09:40 AM
sorry kax! Didn't mean to be ungrateful! :( THANK YOU THANKYOU THANKYOU! :P :P:P
kode
March 2nd, 2003, 09:44 AM
it's ok. i was kidding ;)
but .. i like how it sounds :P
you're welcome =)
cookie
March 2nd, 2003, 01:17 PM
Is it correct to break up this code into 2 functions like this:
ctrl.onRelease = function() {
if (!counting) {
countdowni = setInterval(countdown, 1000);
this.nextFrame();
counting = true;
} else {
clearInterval(countdowni);
this.prevFrame();
counting = false;
}
};
start=function(){
if (!counting) {
countdowni = setInterval(countdown, 1000);
this.nextFrame();
counting = true;
}
}
pause=function(){
clearInterval(countdowni);
this.prevFrame();
counting = false;
}
kax??:P
kode
March 2nd, 2003, 01:39 PM
if it works .. do whatever you want ;)
but i doubt that your script would work .. :-\
if you want to use the same mc to start/pause the countdown
you need the variable counting so the mc knows what to do everytime is clicked
if you use different buttons .. one to start it and another to pause it
i guess you can use something like:
startcount = function() {
countdowni = setInterval(countdown, 1000);
}
pausecount = function() {
clearInterval(countdowni);
}
startctrl.onRelease = startcount;
pausectrl.onRelease = pausecount;
or
startctrl.onRelease = function() {
countdowni = setInterval(countdown, 1000);
}
pausectrl.onRelease = function() {
clearInterval(countdowni);
}
cookie
March 2nd, 2003, 01:49 PM
You're hilarious kax! :P :P I'm being sarkastic!! Well like I said I'm no AS guru!:rambo:
kode
March 2nd, 2003, 01:58 PM
you're hilarious kax!
life is short .. let's make it fun ;)
i'm being sarcastic!!
ok .. don't ever do that again :hair:
:P jk ;)
well like I said I'm no as guru!
me neither :-\
cookie
March 2nd, 2003, 02:02 PM
You're right kax! Life is short! :P =)
You should enjoy it will you can! Life without humour is boring! :P :rambo:
kode
March 2nd, 2003, 02:07 PM
believe me .. i enjoy it :bad: :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.