30秒后停止flash动画

时间:2014-12-24 17:22:23

标签: javascript flash animation

我正在进行闪回倒计时是倒计时,倒计时到指定日期。我喜欢倒计时在玩30秒后停止。我需要做什么?

counter.onEnterFrame = function(){
currentDate = new Date();
currentMillisecs = currentDate.getTime();
this.msecs = eventMillisecs - currentMillisecs;
if (this.msecs <= 0){
    // the event time has been reached!
    // play the next frame for the result of the countdown.     
    play();
    return;
}

1 个答案:

答案 0 :(得分:0)

您可以使用setIntervalsetTimeout,或使用getTimer()跟踪已用时间。

以下是后者的一个例子:

var initalTime = getTimer();
counter.onEnterFrame = function(){
    if(getTimer() - initialTime > 30000) //stop counting

    ....

或setTimeout:

setTimeout(30000, cancelCountdown);

function cnacelCountdown(){
     //stop your countdown
}