嘿,伙计们,我正在尝试让这个倒数计时器走得更快,这样我就可以在它进入下一个级别时对其进行测试……但我正在玩弄这些数字,但它不起作用:(
如果你们能评论一下你们正在做的事情,我对编程很陌生,这对我有帮助
package {
import flash.events.TimerEvent;
import flash.utils.Timer;
public class CountdownTimer extends Timer {
public var time:Number = 0;
public function CountdownTimer(time:Number = Number.NEGATIVE_INFINITY, delay:Number = 1000) {
super(delay, repeatCount);
if (isNaN(time)) {
this.time = 0;
}
else {
this.time = time;
}
repeatCount = Math.ceil(time / delay);
}
启动计时器
override public function start():void {
super.start();
addEventListener(TimerEvent.TIMER, timerHandler);
addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
}
重置计时器
override public function reset():void {
super.reset();
time = 0;
}
protected function timerHandler(event:TimerEvent):void {
time -= delay;
if(time == 0){
trace("time = 0")
}
trace("delay");
trace(time);
}
此标准用于计时器完成
protected function timerCompleteHandler(event:TimerEvent):void {
}
停止计时器
override public function stop():void {
super.stop();
removeEventListener(TimerEvent.TIMER, timerHandler);
removeEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
}
}
}