# Having trouble loading swf

**URL:** <https://forum.kirupa.com/t/having-trouble-loading-swf/294904>\
**Category:** flash\
**Created:** [August 21, 2009, 6:41pm UTC](https://forum.kirupa.com/t/having-trouble-loading-swf/294904 "2009-08-21T18:41:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shazzmoe](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@shazzmoe](https://forum.kirupa.com/u/shazzmoe)\
**Post date:** [August 21, 2009, 6:41pm UTC](https://forum.kirupa.com/t/having-trouble-loading-swf/294904/1 "2009-08-21T18:41:35Z")

</div>

I’m trying to simply have a flash file that acts as a preloader by loading in a separate swf to it. To my understanding it should be simple and the following should work.

```auto

package 
{
    import flash.events.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.media.*;
    import flash.net.*;
    import flash.system.*;
    import flash.utils.*;
    import td.*;    

    public class iceDefensePreloader extends MovieClip
    {

        function iceDefensePreloader()
        {
            var mLoader:Loader = new Loader();
            var mRequest:URLRequest = new URLRequest("IceDefense.swf");
            mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
            mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
            mLoader.load(mRequest);
        }
        
        function onCompleteHandler(loadEvent:Event)
        {
            trace("LOAD COMPLETE"); //THIS NEVER GETS REACHED
            addChild(loadEvent.currentTarget.content);
        }
        
        function onProgressHandler(mProgress:ProgressEvent)
        {
            var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
            trace(percent);
        }
        
    }

}

```

However I get the following error that I hate more than any other.  
TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at td::Main/init()  
at td::Main()

So it almost seems like the error is in my Main class for the swf being loaded… But i dont understand how this can be since that swf works fine when run by itself.
