Skip to main content
Known Participant
November 13, 2006
Question

setInterval problems...

  • November 13, 2006
  • 2 replies
  • 209 views
Hi...

I have a counter on a game that counts down to 0 then moves onto the next frame (the game over frame). There is a button on this frame (the game over frame) that lets the user go back and play again. This is where the porblem occurs. Once they click to go back and play again the setInterval count down timer is messed up and counts down at random speeds...i have a clearInterval on the game over frame and also one in the code of the game that says, if such and such happens go to and play ("game over").

Anybody know why this is?

Thanks..

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
November 14, 2006
you don't need to defined myCounter's data type. but shoud use clearInterval(myCounter) in the line above your setInterval() statement and you need to initalize timer each time your setInterval() executes.
November 13, 2006
have you declared the myCounter as number ??
When you are declaring the id for setInterval , you have set like this
var myCounter:Number; (Dont declared with any initialization).
and also make sure the loop reaches the if condition...