2017-06-01 62 views
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幾年,你能告訴我這裏出了什麼問題嗎?

在此先感謝和快樂編程!

回答

1

你的代碼看起來是正確的,它適用於我,所以問題在你分享的部分之外的某個地方 - 那麼你可以共享所有的項目嗎? 它幾乎沒有幫助 - 但無論如何嘗試flash.events.Event.ENTER_FRAME