1 Reply Latest reply on Apr 18, 2011 5:29 PM by kglad

    Countdown timer before game starts not working AS2


      Hi all


      I have a game which was built in AS2, I am trying to make a countdown timer so the game starts without the start button.


      This is what currently prompts the game to start after "plat_btn" is pressed


      play_btn.onRelease = function ()


          _root.menu.customItems[0].visible = _root.menu.customItems[1].visible = _root.menu.customItems[2].visible = true;

          play ();



      instruction_btn.onRelease = function ()




      _root.menu.customItems[0].visible = _root.menu.customItems[1].visible = _root.menu.customItems[2].visible = false;

      I added the following code before the above lines:
      var countdown_time:Number = 10; var counter:Number = countdown_time;  countdown_txt.autoSize = "right"function countdown() {     counter--;     countdown_txt.text = counter;     if (counter == 0) {         trace("countdown complete");         clearInterval(intID);      } } countdown_txt.text = countdown_time; intID = setInterval(countdown,1000);
      The counter is counting down fine and even says confirm the countdown is complete in the output section when compiled. But how do I get the counter to countdown first and then go straight to the game when it equalls zero?
      I removed //play_btn.onRelease = function () but the game just starts automatically without the countdown,
      Any help would be much appreciated, noob to flash and really trying to make this happen- suprised that its taken me almost 3 hours and still no joy!
      Thanks in advance,