Actionscript timer help!

Discussion in 'Programming' started by TheGeeksPalace, Nov 25, 2009.

  1. #1
    Hello everyone. I am developing a small flash game for school. Here is a quick overview of what it is.

    There is a ball the is being pulled by gravity, wind, friction, and other forces. The objective is to use the arrow keys to keep the ball in the "window" for 30 seconds and then you can move on to the next level. I have used the below code for the timer.
    tm=30; displayTime.text = tm; 
    countDown = function () { tm--; displayTime.text=tm; 
    if (tm==0) { clearInterval(timer); } }; 
    timer = setInterval(countDown, 1000);
    stop();
    
    Code (markup):
    When I first run it, the timer counts down from 30 seconds then goes to the next level. This is fine. But when I click the "reset" button, and then start playing again, the timer counts down really fast. Way faster than it should. Here is the code for the reset button.
    on (release) {
    	gotoAndPlay("Scene 1", 1);
    }
    Code (markup):
    Scene one is the main menu. Then you click play to to go to scene 2.

    Any help will be useful. If you need more information please let me know.
     
    TheGeeksPalace, Nov 25, 2009 IP
  2. sinc

    sinc Peon

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you work with flex or Flash and Action Script.I am learning flex can you help me. Thanks sharing this code.
     
    sinc, Nov 28, 2009 IP