2014-02-23 34 views
1

我已将setInterval设置为10秒。而且它在我的游戏中工作得很好,它从10秒倒数,当它达到0时改变场景。Actionscript 2 Setinterval将毫秒添加到计时器

问题是我真的需要显示毫秒数,而我不知道如何将它添加到反击......它应该很难,但我真的不知道。

下面是脚本:

timer = 10; 
clearInterval(countdownInterval); 
countdown = function(){ 
timer--; 
if (timer ==0){ 
    gotoAndPlay("Scene 1",2); 
} 

} 
countdownInterval = setInterval(countdown,1000); 

回答

0

你可能需要一个Date()对象,它将以毫秒为单位报告的时间差。使用setTimout来增加一个定时器可能会有很多问题。

var startTime = +(new Date) + (10 * 1000); 
var checkFinished = function() { 
    timeRemaining = startTime - (new Date); 
    if(timeRemaining <= 0) { 
     gotoAndPlay("Scene 1",2); 
    } else { 
     setTimeout(checkFinished, 100)l 
    } 
} 
setTimeout(checkFinished, 0);