# Getting a preloader to work

**URL:** <https://forum.kirupa.com/t/getting-a-preloader-to-work/309342>\
**Category:** Uncategorized\
**Created:** [May 12, 2010, 3:11pm UTC](https://forum.kirupa.com/t/getting-a-preloader-to-work/309342 "2010-05-12T15:11:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnyct9760](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@johnyct9760](https://forum.kirupa.com/u/johnyct9760)\
**Post date:** [May 12, 2010, 3:11pm UTC](https://forum.kirupa.com/t/getting-a-preloader-to-work/309342/1 "2010-05-12T15:11:44Z")

</div>

Link to source files:  
[http://www.johncliffordtaylor.com/flaSourceFiles.rar](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:

```php

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:

```php

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!
