# TypeError: #1009 null object reference and a loader

**URL:** https://forum.kirupa.com/t/typeerror-1009-null-object-reference-and-a-loader/241614
**Category:** flash
**Created:** [October 16, 2007, 4:56am UTC](https://forum.kirupa.com/t/typeerror-1009-null-object-reference-and-a-loader/241614 "2007-10-16T04:56:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![forumSteve](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@forumSteve](https://forum.kirupa.com/u/forumSteve)
#### Post date: [October 16, 2007, 4:56am UTC](https://forum.kirupa.com/t/typeerror-1009-null-object-reference-and-a-loader/241614/1 "2007-10-16T04:56:15Z")

</div>

Hi,

I’m having some trouble with the stage in AS3 when loading a swf into another swf.

I have a loader swf loading a swf with a document class which imports a few other classes. A sample from one of those imported classes follows:

```auto
// constructor
        function ModelInfo() {
            if (!allowInstantiation) {
                throw new Error("Error: Instantiation failed: Use ModelInfo.getInstance() instead of new.");
            } else {
                createMouseOverHeading();
                createMouseOverSubHeading();
                createMouseOverDetails();
            }
        }
        public static function getInstance(input:Stage):ModelInfo {
            if (instance == null) {
                myStage = input;
                allowInstantiation = true;
                instance = new ModelInfo();
                allowInstantiation = false;
            }
            return instance;
        }

```

As soon as the progress handler traces that the loader has loaded the entire swf (but before the init handler gets executed) I receive 1009 null object reference errors everywhere the stage is accessed.

Now… unfortunately, general confusion does not make for a very good question…so,

Should the “addchild” for the loaded swf be on on the loader’s onComplete handler, or somewhere else?  
I’ve read about “ADDED\_TO\_STAGE” in several places, but how can I incorporate this into the above code?  
Should the swf that is loaded compile properly on it’s own to work with the loader?  
Can anyone refer a good article that explains the problem I’m having? I’ve already tried several and I’m not confident that I understand it.

Thanks in advance 🙂
