我正在进行闪回倒计时是倒计时,倒计时到指定日期。我喜欢倒计时在玩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;
}
答案 0 :(得分: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
}