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