By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,606 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,606 IT Pros & Developers. It's quick & easy.

Need help with a countdown script

P: 1
Hi there.

Im very new to making games in flash, although I have used flash for quite some time now in web-based situations so I know my way around.
Anyways, I thought it would be fun to try making some sort of game and I got stuck… :P I managed to get a clock counting down from 30 to 0 and then collect the score but I get in trouble when i try to make a button that restarts the procedure since i then get the doubled clock speed counting down, i fixed this by making two versions of the same thing one with -1 in time and one with -0 that would be used for restarting and it worked flawlessly, until now.
I made a second game-style in the menu and then i need to have -1 in time there if someone wants to start there so back at square one… Is there anyway to reset the scripts for time when the score is collected so that when I start over I dont get the double script? my script for the countdown looks like this:

setInterval(countdown,1000); time = 30; function countdown() { time = time-1; if (time<=0) { gotoAndStop(“done”); } }

It cant be that setInterval(countdown,1000); gets doubled because then it would take twice as long time for each second to tick down and it goes faster so thats not the problem, and it can be the { time = time-1; that gets doubled either, then it would tick down 2 numbers for each second…? I really dont have any clue to why I get a faster countdown in the time when i restart…

Here’s how it behaves:
1st time: all normal
2nd time: 30 normal 29,28 fast, 27 normal, 26,25 fast, 24 normal and so on
3rd time: 30,29,28 fast 27 normal, 26,25,24 fast…
And it just keeps increasing in speed for every time I restart…

Any ideas?
Jan 10 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.