Timer for narrative
stop();
//Starting number of the countdown
var count:Number = 10;
//create new timer
var myTimer:Timer = new Timer(1000, count);
//create event listener
myTimer.addEventListener(TimerEvent.TIMER, countdown);
//start the timer
myTimer.start();
//countdown function
function countdown(event:TimerEvent):void {
myText_txt.text = String((count) -myTimer.currentCount);
//if timer reaches "0" you lose
if(myText_txt.text == "0"){
gotoAndStop(6);
}
//first part of sequence
stage.addEventListener(KeyboardEvent.KEY_DOWN, goto2);
function goto2(e:KeyboardEvent):void {
if (e.keyCode == 49) {
gotoAndStop(2);
}
}
}
No comments:
Post a Comment