# Error #1009: Driving me crazy

**URL:** <https://forum.kirupa.com/t/error-1009-driving-me-crazy/322849>\
**Category:** flash\
**Created:** [June 6, 2011, 2:34am UTC](https://forum.kirupa.com/t/error-1009-driving-me-crazy/322849 "2011-06-06T02:34:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TehWut](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@TehWut](https://forum.kirupa.com/u/TehWut)\
**Post date:** [June 6, 2011, 2:34am UTC](https://forum.kirupa.com/t/error-1009-driving-me-crazy/322849/1 "2011-06-06T02:34:25Z")

</div>

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

```auto
TypeError: Error #1009: Cannot access a property or method of a null object reference.

```

The code in the DocumentClass: set as DocumentClass.

```auto
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:

```auto
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();

```
