# Error #1009 - Only when added as child? \*Urgent\*

**URL:** <https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253>\
**Category:** flash\
**Created:** [July 7, 2008, 2:06am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253 "2008-07-07T02:06:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 7, 2008, 2:06am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253/1 "2008-07-07T02:06:54Z")

</div>

Ok, heres the problem… I have my game which works perfect, then when I try to use my loader… This happens.

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at buggyWars\_fla::MainTimeline/buggyWars\_fla::frame1()

Why would my loader be causing errors in my game swf? Btw, this is testing locally.

My Loader:

```auto

stop();
var Version = root.loaderInfo.parameters.Version;
//var request:URLRequest = new URLRequest("buggyWars.swf?" + Version);
var request:URLRequest = new URLRequest("buggyWars.swf");
var gameLoader:Loader = new Loader();
gameLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
gameLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadProgress(event:ProgressEvent):void {
    var Percent:Number = event.bytesLoaded / event.bytesTotal;
    Percent = Math.round(Percent * 100);
    loadingBox.loadingText.text = "Loading... " + Percent + "%";
}
function loadComplete(e:Event):void {
    this.removeChild(loadingBox);
    this.addChild(gameLoader);
}
gameLoader.load(request);

```

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [July 7, 2008, 2:26am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253/2 "2008-07-07T02:26:36Z")

</div>

> **[kirupaForum](https://forum.kirupa.com)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

:thumb:

---

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 7, 2008, 4:30am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253/3 "2008-07-07T04:30:02Z")

</div>

Awesome! I just spent an hour turning 719 lines of timeline code into a Document class.

It works! Sweet…

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [July 7, 2008, 5:23am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253/4 "2008-07-07T05:23:59Z")

</div>

I should clarify - the important part is making sure nothing runs until the ADDED\_TO\_FRAME event - but welcome to the world of classes! That’s excellent. :beam:

---

<div class="post-metadata">

**Author:** ![DesignerMichael](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DesignerMichael](https://forum.kirupa.com/u/DesignerMichael)\
**Post date:** [July 7, 2008, 5:49am UTC](https://forum.kirupa.com/t/error-1009-only-when-added-as-child-urgent/265253/5 "2008-07-07T05:49:41Z")

</div>

I got that. 🙂 All of my game elements were classes… Projectiles, etc…

I am not sure why I had my main script on the Timeline. Easier to reach I guess. 😕
