stage.addEventListener(MouseEvent.CLICK, stageclicked);
if{ function stageclicked(event:MouseEvent):void
}
else{
//1.
var count3:Number = 4;
//2.
var myTimer3:Timer = new Timer(1000,count3);
//3.
myTimer3.addEventListener(TimerEvent.TIMER, countdown3);
//4.
myTimer3.start();
//5.
function countdown3(event:TimerEvent):void {
resttimer.text = String((count3)-myTimer3.currentCount);
if(resttimer.text == "0"){
gotoAndStop(1);
}
}
我想在舞台上添加鼠标点击事件。它应该是这样的,如果有人没有点击舞台,那么倒计时应该开始。当它变为“0”时,它应该播放其他场景。
答案 0 :(得分:1)
试试这个:
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.CLICK, stageClicked);
var count:int = 4;
var myTimer:Timer = new Timer(1000,count);
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, onCount);
function onCount(e:TimerEvent):void
{
count --;
resttimer.text = String(count);
}
function stageClicked(e:MouseEvent):void
{
count = 4;
resettimer.text = String(count-1);
myTimer.reset();
myTimer.start();
}