# \[AS3\] Problems with a SWF preloader

**URL:** <https://forum.kirupa.com/t/as3-problems-with-a-swf-preloader/213136>\
**Category:** flash\
**Created:** [January 17, 2007, 5:47am UTC](https://forum.kirupa.com/t/as3-problems-with-a-swf-preloader/213136 "2007-01-17T05:47:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdoob](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mrdoob/32/3191_2.png) [@mrdoob](https://forum.kirupa.com/u/mrdoob)\
**Post date:** [January 17, 2007, 5:47am UTC](https://forum.kirupa.com/t/as3-problems-with-a-swf-preloader/213136/1 "2007-01-17T05:47:05Z")

</div>

This is a preloader.swf source code I’ve been doing…

```auto

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;
    import flash.text.*;

    public class preloader extends Sprite
    {
        private var f:String = "http://www.rockonflash.com/demos/pv3d/macworld/demo/as3/Falcon3D_cameraFollow.swf";
        private var tf:TextField = new TextField();
        private var container:MovieClip;

        public function preloader()
        {

            var loader:Loader = new Loader();
            var container= new MovieClip();

            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
            
            var request:URLRequest = new URLRequest(f);
            loader.load(request);
            
            addChild(container);
            
        tf.autoSize = TextFieldAutoSize.LEFT;
        tf.textColor = 0xFF0000;
        addChild(tf);
        tf.text = f;
            
        }
        
    private function onLoadProgress (event:ProgressEvent):void
    {
        var loaded:int = event.bytesLoaded;
        var total:int = event.bytesTotal;
        var percent:int = loaded/total*100;
        tf.text = "Loading: "+String(percent)+"%";
    }        

        private function completeHandler(event:Event):void {
            container = MovieClip(event.target.content); 
        }                
    }
}

```

It compiles alright, but when it loads the other .swf it gives that error:

```auto

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

```

Which looks like if isn’t able to initialise the main class of the SWF loaded. Does anyone know what am I doing wrong? What’s the best way to load dinamicly a SWF into another SWF?

Help pleeease! :\_(
