好的,我对 Actionscript 3 很陌生
我希望我的计时器指示正在玩我的游戏的人在计时器完成时(00:00)进入“游戏结束”屏幕。目前我收到一条错误消息:“1067:将 Class 类型的值隐式强制转换为不相关的 flash.display:DisplayObject 类型。”
有任何想法吗?
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class SecondCounter extends MovieClip {
private var myTimer:Timer=new Timer(1000,0);
private var secs:Number=10;
private var mins:Number=0;
private var sec_t:String;
private var min_t:String;
var screen7:EndScreen;
public function SecondCounter() {
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.start();
}
private function timerHandler(evt:TimerEvent):void {
if (secs==0) {
if (mins==0) {
addChild(EndScreen);
} else {
mins--;
secs=59;
}
} else {
secs--;
}
if(secs<10){
sec_t = "0"+String(secs)
} else {
sec_t = String(secs);
}
if(mins<10){
min_t = "0"+String(mins) +":"
} else {
min_t = String(mins)+":";
}
secondField.text = min_t + sec_t;
}
}
}