# Loading SWF Error

**URL:** <https://forum.kirupa.com/t/loading-swf-error/252539>\
**Category:** flash\
**Created:** [February 21, 2008, 2:26am UTC](https://forum.kirupa.com/t/loading-swf-error/252539 "2008-02-21T02:26:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmkozlow](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jmkozlow](https://forum.kirupa.com/u/jmkozlow)\
**Post date:** [February 21, 2008, 2:26am UTC](https://forum.kirupa.com/t/loading-swf-error/252539/1 "2008-02-21T02:26:58Z")

</div>

Hi Everyone. I am newbie and I am pleading for help to get me through this project. A friend told me to come here said you all were the best. I haven’t really found and solution to the problem I am having because, to most programmers, the problem is very simple. Here is my problem. [URL=“[http://www.aestyria.com/jmkozlow.zip](http://www.aestyria.com/jmkozlow.zip)”]Download my files[/URL

In frame 1 of MainLoader.swf (basically just a preloader) I have this code:

```auto

preloader_mc.stop();
preloader_mc.visible=false;

var swf:String='Main.swf';
var richiesta:URLRequest=new URLRequest(swf);
var loader:Loader=new Loader();

loader.contentLoaderInfo.addEventListener(Event.OPEN,openMC);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,working);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,done);
loader.load(richiesta);

function openMC(e:Event):void
{
	preloader_mc.visible=true;
	preloader_mc.play();
}

function working(e:ProgressEvent):void
{
	var percentage:uint=(e.bytesLoaded/e.bytesTotal)*100;
	preloader_mc.loader_txt.text='loading '+percentage.toString()+'%';
}

function done(e:Event):void
{
	preloader_mc.stop();
	preloader_mc.visible=false;
	addChild(loader);
}

```

This used to load “Main.swf” but now that I have added a document class “Main.as” to control my main menu. I get an error when I launch “MainLoader.swf.”

> TypeError: Error #1009: Cannot access a property or method of a null object reference.  
> at Main/::init()  
> at Main$iinit()

Basically, how do I load a swf and it’s class into a preloader like this. I am open to any other suggestions or help to make this project more efficient. You can get the files [here](http://www.aestyria.com/jmkozlow.zip). Everything is bare bones.

Thanks!

jmkozlow
