# Preloader help!

**URL:** <https://forum.kirupa.com/t/preloader-help/317019>\
**Category:** Uncategorized\
**Created:** [December 8, 2010, 5:17am UTC](https://forum.kirupa.com/t/preloader-help/317019 "2010-12-08T05:17:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shanzilla](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@shanzilla](https://forum.kirupa.com/u/shanzilla)\
**Post date:** [December 8, 2010, 5:17am UTC](https://forum.kirupa.com/t/preloader-help/317019/1 "2010-12-08T05:17:54Z")

</div>

Sorry for the uneducated post, I’m not quite sure if this is the proper place to ask this. I need some help getting an AS3 preloader to function properly with the actual content it is supposed to be loading.

I’ve read the previous post regarding the issue, (which I found in google and hence created an account specifically to make this thread).

The error I’m getting is this:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at main\_fla::MainTimeline/frame2()  
at flash.display::MovieClip/gotoAndPlay()  
at main\_fla::MainTimeline/onComplete()

The codes I’ve been using are as follows:

**PRELOADER:**

stop();

this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);  
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onProgress(e:ProgressEvent):void  
{  
var loaded:Number = e.target.bytesLoaded;  
var total:Number = e.target.bytesTotal;  
var pct:Number = loaded/total;  
loader\_mc.scaleX = pct;  
loaded\_txt.text = "Loading… " + (Math.round(pct \* 100)) + “%”;  
}

function onComplete(e:Event):void  
{

```
this.gotoAndPlay("2");

```

}

**WEBSITE:**

stop();

//Declaring the requests, loader, and container variables.  
var about: URLRequest = new URLRequest(“about.swf”);  
var bakery: URLRequest = new URLRequest(“bakery.swf”);  
var cafe: URLRequest = new URLRequest(“cafe.swf”);  
var contact: URLRequest = new URLRequest(“contact.swf”);

//Single loader and container.  
var mainLoader:Loader= new Loader();  
var myContainer: MovieClip = new MovieClip();  
addChildAt(myContainer,1) //Puts container on stage.  
addChild(mainLoader);  
//Buttons  
about\_btn.addEventListener(MouseEvent.CLICK, aboutClick);  
function aboutClick(Event:MouseEvent):void  
{  
mainLoader.load(about);  
/_myContainer.addChild(mainLoader);_/  
}

bakery\_btn.addEventListener(MouseEvent.CLICK, bakeryClick);  
function bakeryClick(Event:MouseEvent):void  
{  
mainLoader.load(bakery);  
/_myContainer.addChild(mainLoader);_/  
}

cafe\_btn.addEventListener(MouseEvent.CLICK, cafeClick);  
function cafeClick(Event:MouseEvent):void  
{  
mainLoader.load(cafe);  
/\* myContainer.addChild(mainLoader);\*/  
}

contact\_btn.addEventListener(MouseEvent.CLICK, contactClick);  
function contactClick(Event:MouseEvent):void  
{  
mainLoader.load(contact);  
/\* myContainer.addChild(mainLoader);\*/  
}

Any help would be greatly appreciated. If someone would like the files, I can email them to you 🙂
