Child MC preloader issues

Hi,

I’ve hit a brick wall with regards to a parent movie loading a child mc with a preloader. The idea being, if the child is displayed on the screen, and hasn’t fully loaded, then you view the preloader.

Each mc (parent & child) work fine independently. It’s when the parent loads the child, the child sits there stunned on the first frame. I’m very new to AS3 and am still grappling with loading movies/preloaders etc.

I’m also having issues with setting the contents of a loader in a MovieClip variable. The below code is fine, but when I try and reference the x and y of _lounge rather than the loader _loungeL, it gives me “Error #1009: Cannot access a property or method of a null object reference”. I’m guessing it’s saying the MC doesn’t exist???

Thanks in advance for any assistance!

All files can be viewed here: http://www.darrellwhite.com.au/Archive.zip

Here is the AS of the main mc

package
{
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldType;

public class main extends MovieClip
    {

        var playersName:String;
        private var _loungeL:Loader = new Loader();
        private var _lounge:MovieClip = new MovieClip();
        private var _activeRoom:MovieClip;
        private var _outgoingRoom:MovieClip;
        public var playersTips:Array = new Array();
      
        
        public function main()
        { 
            init();
            this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, preload); //start up the preloader
            addChild(_loungeL)
            loadLounge();
        }
        
        private function init():void
        {
            playersTips = [false, false];
            var playersName = "";
        }

//Start preloader

        private function preload(event:ProgressEvent):void 
        {
            var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
            
            mainLoaderTxt.text = Math.ceil(pcent).toString() + "% loaded";
            if(pcent==100)
            {
                gotoAndPlay(2);
                this.loaderInfo.removeEventListener (ProgressEvent.PROGRESS, preload);
            }
        }
        //End preloader
        
        //Load movies in the background
        
        private function loadLounge():void
        {
            var url:URLRequest = new URLRequest("loungeroom.swf"); 
            _loungeL.load(url);
            _lounge = MovieClip(_loungeL.content);
            _loungeL.x = 2000;
            _loungeL.y = 150;
        }
        //End loading main movies
        
        public function moveLounge():void
        {
            _loungeL.x = 20;
            _loungeL.y = 150;
            this.swapChildren(homePage_mc, _loungeL);
        }
    }

}

the child script is this…

package
{
import flash.events.MouseEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.display.*;
import flash.events.ProgressEvent;

public class loungeRoom extends MovieClip
    {
var objPanelContainer:objectPanel_mc;
        var cancelButtonContainer:cancel_btn;
        var okButtonContainer:ok_btn;

        
        public function loungeRoom()
        {
            
            this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, loungePreload); //start up the preloader

        }
        //Start preloader
        
        
        private function loungePreload(event:ProgressEvent):void 
        {
            var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
            
            percent.text = Math.ceil(pcent).toString() + "% loaded";
            if(pcent==100)
            {
                this.gotoAndPlay(4);
                this.loaderInfo.removeEventListener (ProgressEvent.PROGRESS, loungePreload);
            }
        }

        //End preloader
    
    }

}