Flash 定时器-如何停止它?AS2
我正在学习如何为我的游戏制作计时器。就像“谁想成为百万富翁?”我有15个问题。每个问题都有计时器:60秒。。。。当我点击一个答案时,我进入下一帧,但我的计时器并没有停止。当我点击答案时,我应该添加什么(以及在哪里)来停止计时器?(Flash Professional CS 5/ActionScript 2)我的计时器代码是:Flash 定时器-如何停止它?AS2,flash,actionscript,flash-builder,actionscript-2,flash-cs5,Flash,Actionscript,Flash Builder,Actionscript 2,Flash Cs5,我正在学习如何为我的游戏制作计时器。就像“谁想成为百万富翁?”我有15个问题。每个问题都有计时器:60秒。。。。当我点击一个答案时,我进入下一帧,但我的计时器并没有停止。当我点击答案时,我应该添加什么(以及在哪里)来停止计时器?(Flash Professional CS 5/ActionScript 2)我的计时器代码是: timer = 60; countdown = function(){ _root.timer--; if(_root.timer<=0){
timer = 60;
countdown = function(){
_root.timer--;
if(_root.timer<=0){
gotoAndPlay(20); stop();
}
}
countdownInterval = setInterval(countdown,1000);
定时器=60;
倒计时=函数(){
_root.timer--;
如果(_root.timer试试这个
var timer:Timer = new Timer();
public function startTimer(n:Number):void{ //n = number of seconds you want to run the timer
t.repeatCount = n;
t.start();
t.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
}
public function timerComplete(event:TimerEvent):void{
t.removeEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
//What ever you want to do when timer is up.
}
希望有帮助!在您的nextFrame()或调用gotoAndPlay(20);
希望这有帮助(如果您仍然需要)
@AndrewBramwell是的,是的。有人能解释一下为什么会被标记下来吗?据我所知,问题是如何停止AS2计时器,我的答案是停止和AS2计时器的最简单方法。。。
clearInterval(countdownInterval);