1
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”时,它应该播放一些其他场景。

4

1 回答 1

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();
}
于 2013-07-20T06:54:29.457 回答