# Null object using preloader

**URL:** https://forum.kirupa.com/t/null-object-using-preloader/275906
**Category:** Uncategorized
**Created:** [November 19, 2008, 10:47pm UTC](https://forum.kirupa.com/t/null-object-using-preloader/275906 "2008-11-19T22:47:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [November 19, 2008, 10:47pm UTC](https://forum.kirupa.com/t/null-object-using-preloader/275906/1 "2008-11-19T22:47:41Z")

</div>

I have a swf that is called preloader.swf…All it does is preload my main movie. The code for my preloader is:

```auto

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));

function loop(e:ProgressEvent):void
{
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    preloader.txt.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
    removeChildAt(0);
    preloader.txt = null;
    addChild(l);
}

```

and my content.swf contains:

```auto

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, resizeHandler);
function resizeHandler(e:Event):void
{
    header.width = stage.stageWidth + 100;
    bgClip.y = 0;
    bgClip.x = 0;
    bgClip.width = stage.stageWidth;
    bgClip.height = stage.stageHeight;
    bgClip.scaleX > bgClip.scaleY ? bgClip.scaleY = bgClip.scaleX : bgClip.scaleX = bgClip.scaleY;
}
resizeHandler(null);

```

I am assuming the null reference is talking about the references to stage. I am getting this error:

```auto

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

```

What am I doing wrong here?
