(CS3 AS2) Preloading all images in XML

Hi eveyone,

I’ve adapted a tutorial from here (xml photogallery) but I really need some help preloading all the images listed in my xml.

I’ve searched around and seem some other examples but nothing that I
really can apply and to be honest, with some of them I got completely
lost! (I’m obviously a designer rather than coder)

Any help would be hugely appreciated.


//IMAGES

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        caption = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            caption* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("../xmlfile.php");
///////////////////////////////////// 
listen = new Object();
listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
        prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
        nextImage();
    }
};
Key.addListener(listen);
prevBt.onRelease = function() {
    prevImage();
};
nextBt.onRelease = function() {
    nextImage();
};
///////////////////////////////////// 
p = 0;
this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (picture._alpha<100) {
            picture._alpha += 2;
        }
    }
};
function nextImage() {
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p], 1);
            captions.text = caption[p];
            picture_num();
        }
    }
}
function prevImage() {
    if (p>0) {
        p--;
        picture._alpha = 0;
        picture.loadMovie(image[p], 1);
        captions.text = caption[0];
        picture_num();
    }
    if (p<0){
        prev._alpha = 0;
    }
    if (p>0) {
        prev._alpha = 100;
    }
}
function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0], 1);
        captions.text = caption[0];
        picture_num();
    }
}
function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
} 

XML


     <?xml version="1.0"?>
<images>
<pic>
<image>Arch_10.jpg</image>
<caption>yadda yadda yadda</caption>
</pic>
<pic>
<image>Arch_11.jpg</image>
<caption>more yadda yadda</caption>
</pic>
<pic>
<image>Arch_46_47.jpg</image>
<caption>yadda yadda again</caption>
</pic>
</images>