It’s me again, my game is giving me some problems. Basically, I moved all the “game code” into a MovieClip called “PlayScreen” (previously “FightingGame”). Then I created a new DocumentClass file and set it as the Document Class. for some reason, when trying to add a child its basically saying that the object is null, though I have no idea why.
line 32 for “FightingGame” @ stage.AddEventListener
line 9 for “DocumentClass” @ addCHild
TypeError: Error #1009: Cannot access a property or method of a null object reference.
The code in the DocumentClass: set as DocumentClass.
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class DocumentClass extends MovieClip
{
//New Constructor
public var playscreen:FightingGame = new FightingGame;
public function DocumentClass()
{
addEventListener(Event.ADDED_TO_STAGE, FightingGameBuild, false, 0, true);
}
//Old Constructor
public function FightingGameBuild(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, FightingGameBuild);
trace("new constructor");
addChild(playscreen);
}
}
}
Here is the relevant part of the FightingGame Code:
public function FightingGame() {
buildLevel();
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownlistener);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuplistener);
gametimer = new Timer(25);
gametimer.addEventListener(TimerEvent.TIMER,Update);
gametimer.start();