0
因此,我有2個場景中的計時器。第一場景中的計時器完美運作。但是,當我嘗試到第二個場景時,計時器變得如此之快。 我有2組代碼:Actionscript 2定時器快速降低
_root.timer = 10;
clearInterval(id);
id = setInterval (function()
{
_root.timer--;
if(timer==0)
{
gotoAndStop(65);
}
}, 1000);
與此:
timer = 10;
timer.text= timer;
countdown = function(){
timer--;
if(timer==0){
clearInterval(countdownInterval);
gotoAndStop(65);
}
}
countdownInterval = setInterval(countdown,1000);
我知道,1000毫秒= 1秒。我只是不知道是什麼導致計時器在第二個場景中快速下降。你怎麼看?
明白了。謝謝。呃,可以暫停並播放定時器嗎?我的意思是說,沒有重新設置它。它會在停止的地方播放。也許,通過使用按鈕。非常感謝你。 – user1587341 2012-08-14 16:47:39
我不知道AS2的定時器實現,但在AS3中它漂亮的東西,用新的Timer()創建定時器對象;並使用timer.reset(); timer.start();但是,如果將函數定義爲全局函數,則將函數定義爲clearInterval和setInterval。 – 2012-08-14 18:15:59