I'm trying to develop a simple game in Adobe Animate and AS3.
I have a class GameCore
where I want to add an ENTER_FRAME event listener.
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;
}
}
}
When I try to execute the code on a timeline frame like so:
import as3.GameCore;
var game:GameCore = new GameCore(stage);
It throws an error saying:
CanĀ“t access probably undefined property ENTER_FRAME referenced with static type Class
i did this before, but i don't touch as3 for a couple of years, can you tell me whats going wrong here?
Thanks in advance and happy programming!