0
我想在Adobe Animate和AS3中開發一個簡單的遊戲。AS3 - Event.ENTER_FRAME - 錯誤1119
我有一個類GameCore
我想添加一個ENTER_FRAME事件偵聽器。
package as3 {
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.*;
import as3.movieclips.RocketShip;
public class GameCore {
var rocket:RocketShip;
var stage:Stage;
var timeline:MovieClip;
var i:int;
public function GameCore(stage:Stage) {
// constructor code
this.rocket = new RocketShip();
this.stage = stage;
this.timeline = this.stage as MovieClip;
this.i = 0;
this.stage.addEventListener(Event.ENTER_FRAME, gameLoop);
}
public function goToMainScreen():void {
this.timeline.goToAndStop("MainScreen");
}
public function goToGameScreen():void {
this.timeline.goToAndStop("GameScreen");
}
public function startGameLoop():void {
}
public function gameLoop(event:Event){
trace(this.i);
this.i += 1;
}
}
}
當我嘗試到時間軸幀上執行的代碼如下所示:
import as3.GameCore;
var game:GameCore = new GameCore(stage);
它拋出一個錯誤說:
Can´t access probably undefined property ENTER_FRAME referenced with static type Class
我這樣做過,但我不」 t觸摸as3幾年,你能告訴我這裏出了什麼問題嗎?
在此先感謝和快樂編程!