2014-12-24 113 views
0

我正在運行Flash倒計時是倒計時到指定日期的倒計時。我想在倒計時30秒後停止。我需要做什麼?30秒後停止Flash動畫

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; 
} 

回答

0

你可以使用setInterval,或setTimeout或追蹤getTimer()經過的時間。

下面是後者的一個例子:

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

    .... 

或者setTimeout的:

setTimeout(30000, cancelCountdown); 

function cnacelCountdown(){ 
    //stop your countdown 
} 
+0

感謝讓計時器工作對我來說 – rivkyros