# Passing the stage through than one class

**URL:** https://forum.kirupa.com/t/passing-the-stage-through-than-one-class/305977
**Category:** flash
**Created:** [March 7, 2010, 1:50am UTC](https://forum.kirupa.com/t/passing-the-stage-through-than-one-class/305977 "2010-03-07T01:50:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Kainevg](https://avatars.discourse-cdn.com/v4/letter/k/278dde/32.png) [@Kainevg](https://forum.kirupa.com/u/Kainevg)
#### Post date: [March 7, 2010, 1:50am UTC](https://forum.kirupa.com/t/passing-the-stage-through-than-one-class/305977/1 "2010-03-07T01:50:48Z")

</div>

Hey guys,

So basically this is what I need to happen…

In my document class “Engine” I need to make my “Game Handler” class which is done in the constructor by using:

```auto
var Game:GameHandler = new GameHandler(stage);

```

As you can see, im passing the stage into it… now in my GameHandler class  
it recieves this by:

```auto
private var stageRef:Stage
 
  public function GameHandler (stageRef:Stage)
  {
   this.stageRef = stageRef
   addEventListener(Event.ENTER_FRAME, loop);
  }

```

And now I can access the stage by using stageRef in that class, that works fine but the GameHandler class creates another variable which need to be able to access the stage, which will create other classes that need to have access to the stage… I’ve tried:

```auto
var Survival:SurvivalMode = new SurvivalMode(stage);

```

But I get a whole lot of TypeError: 1009’s…

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at com.senocular.utils::KeyObject/construct()  
at com.senocular.utils::KeyObject()  
at com.main.platformer::Character()  
at com.main.platformer::SurvivalMode()  
at com.main.platformer::GameHandler/loop()

As you can see im using senoculars key object class which alot of you probably know what it is (adds the isDown functionality that was in AS2)…

I really don’t know what do do… Any help would be greatly appreciated
