Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Timer freaking out, can't find the problem!

$
0
0

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"

          }

}


Viewing all articles
Browse latest Browse all 13519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>