Getting a preloader to work

Link to source files:
http://www.johncliffordtaylor.com/flaSourceFiles.rar

Hey every one I’m trying to get a preload movie clip (loaderMovieClip_mc) to show up when an image is being pulled from the xml data bank and then turn the visibility to false when the image is done loading. I have no idea what I’m doing wrong any bump in the right direction would be very cool.

Error message:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at flashIndex6_fla::MainTimeline/frame1()

I think there is a conflict happening between the unloading of the imageLoader:Loader class:


function checkerF(event:TimerEvent):void {     if (imageLoader!=null) {         pictureContainer_mc.removeChild(imageLoader);         imageLoader.unload();     }

and then the preloader is calling it to try and recive the incoming XML data to display on screen:


imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
function loadProgress(event:ProgressEvent):void{   
    var dataLoaded:Number = event.target.bytesLoaded;
    var total:Number = event.target.bytesTotal;
    var percent_loaded:Number = (dataLoaded / total) * 100;
    if(percent_loaded < 10){
            loaderMovieClip_mc.visible = true;
            loaderMovieClip_mc.loaderText_txt.text = '0' + int(percent_loaded);
    }
    else{
            loaderMovieClip_mc.loaderText_txt.text = String(int(percent_loaded));
            }
    if(event.bytesLoaded == event.bytesTotal)   {
            loaderMovieClip_mc.loaderText_txt.text = "";
            loaderMovieClip_mc.visible = false;
            }
}

Not sure if that’s the right direction but its the best idea I have at this point.
I have tried commenting out the imageLoader unload code but that didn’t resolve the issue.

Thank you in advance gents!