How to make 'game over' appear when timer hits 0 AS3


so new using animate , as3 , can't find how make  'game over'  appear on screen when timer runs out. making escape game , have made timer countdowns 90 seconds when gets 0 want game over. instead nothing.

 

here actionscript have used timer:

 

//timer

var ncount:number = 90;

var mytimer:timer = new timer(1000, ncount);

timer_txt.text = ncount.tostring();

mytimer.start();

mytimer.addeventlistener(timerevent.timer, countdown);

 

function countdown(e:timerevent):void

{

ncount--;

timer_txt.text = ncount.tostring();

}

 

but need add in order make 'game over' pop when timer hits 0? have created game on screen on second frame on timeline.

 

thanks!

function countdown(e:timerevent):void

{

     ncount--;

     timer_txt.text = ncount.tostring();

 

     if(ncount == 0){

          mytimer.stop();

          mytimer.removeeventlistener(timerevent.timer, countdown);

          gotoandstop(2);

     }

 

}



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Reader DC

AdobeIDの作り方

Adobe InDesign CC 2017 has stopped working