Help with Preloading Images with an XML file

Ok, so I have an XML based gallery with AS3. Everything works fine locally. But when I upload load it to my site, the animations for the images are all messed up because the image still has to load. But after you have already loaded the image and go back to the the animation works fine because the image has already been loaded. I tried to use a counter to upload all the images as soon as the window opens then remove everything. but it didn’t seem to do anything except give me a bunch of errors…

Help? Please?

Here’s the code and i have my timer preload commented out:

import fl.transitions.*;
import fl.transitions.easing.*;

var xml:XML;
var count:int;
var imageLoader:Loader;
var imageCaption:String;

var myrequest:URLRequest = new URLRequest("Popetstown.xml");
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, xmlLoderCompleteHandler);
xmlLoader.load(myrequest);

function xmlLoderCompleteHandler(e:Event):void {
    xmlLoader.removeEventListener(Event.COMPLETE, xmlLoderCompleteHandler);
    xml = XML(xmlLoader.data);
    
    loadCurrent(xml.image[count].imageCaption, xml.image[count].imageSource);
    
    xmlLoader = null;
}





function loadCurrent(imageCaption:String, imageSource:String):void {
    trace("imageCaption:",imageCaption, "	imageSource:", imageSource);
    this.imageCaption = imageCaption;
    
    var request:URLRequest = new URLRequest(imageSource);
    if (imageLoader != null) {
        unloadCurrent();
    }
    imageLoader = new Loader();
    imageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaderInitHandler);
    imageLoader.load(request);
    
    
        
}

function unloadCurrent():void {
    imageLoader.contentLoaderInfo.removeEventListener(Event.INIT, imageLoaderInitHandler);
    imageLoader = null;
}



function imageLoaderInitHandler(event:Event):void {
    var bitmap:Bitmap = Bitmap(imageLoader.content);
    holder_mc.addChild(bitmap);
    caption.text = imageCaption;


}

//PRELOADER ATTEMPT

/*holder_mc.addEventListener(Event.ENTER_FRAME, preload);


function preload(event:Event):void {
    switch(event.target) {
        case holder_mc:
            var timer:Timer = new Timer(1);
            timer.addEventListener(TimerEvent.TIMER, loadup);
            timer.start();
            function loadup(TimerEvent:Event){
            count++;            
            }
            if (holder_mc.numChildren > 50){
            timer.stop();
            holder_mc.removeChild(imageLoader.content);
            }
            break;
            }
}*/

nextPic.addEventListener(MouseEvent.CLICK, clickHandler);
prevPic.addEventListener(MouseEvent.CLICK, clickHandler);


function clickHandler(event:MouseEvent):void {
    switch(event.target) {
        case nextPic:
            if (holder_mc.numChildren > 1){
            //trace("works");
            holder_mc.removeChild(imageLoader.content);
            }
            count++;            
            //var nexttween:Tween = new Tween(holder_mc, "x", Strong.easeOut, 290, 240, 1, true);
            var nextfade:Tween = new Tween(holder_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
            break;
        case prevPic:
            if (holder_mc.numChildren > 1){
            //trace("works");
            holder_mc.removeChild(imageLoader.content);
            }
            count--;            
            //var prevtween:Tween = new Tween(holder_mc, "x", Strong.easeOut, 190, 240, 1, true);
            var prevfade:Tween = new Tween(holder_mc, "alpha", Strong.easeOut, 0, 1, 1, true);
            break;
    }
    
    if (count == xml.image.length()) {
        count = 0;
    } else if (count < 0) {
        count = xml.image.length() - 1;
    }
    
    loadCurrent(xml.image[count].imageCaption, xml.image[count].imageSource);
}