1 Reply Latest reply on Jan 15, 2014 6:03 AM by kglad

    Timer freaking out, can't find the problem!

    KayKiffen

      Hey Guys,

       

      im a beginner with flash and im having some problems with my timer. It should be counting down till 0 from 100 and then show 'Game Over'

      It just freaks out and goes in 1 second from 100 to - ?? and just keeps flickering the message then. I was wondering if any of u could help me with problably this very simple problem

       

      Here is all my time related code, can u see the mistake?

       

      import flash.utils.Timer;

      import flash.events.TimerEvent;

      import flash.events.Event;

       

      ar gameTimer:Timer = new Timer(1000,0) ;

      var time                     = 100                         ;

       

      gameTimer.start( )                                                                          ;

      gameTimer.addEventListener(TimerEvent.TIMER, timerHandle   );

      gameTimer.addEventListener(TimerEvent.TIMER   , onTick         );

       

      gameTimer.delay       =    25;

      gameTimer.repeatCount = 0;

       

       

       

       

      function timerHandle(e:TimerEvent)

      {

                txt_time.text = time;

                time--;

       

      }

       

       

      addEventListener(Event.ENTER_FRAME,loop)

      function loop(e:Event){

                if(time <= 0) {

                          txt_time.text = "GAME OVER"

                }

      }