AS2: XML Gallery w/grid thumb, loading thumbs in reverse order?

Hi, I’d appreciate any help someone could give. I’ve worked out how to get the gallery to display my thumbnails in a grid pattern but now the grid is starting with the last image in my XML file and displaying them in reverse order. For obvious reasons I need the first image in the grid to be the first image, and not display them in reverse order! Please help if you can :smiley: my code is here.

stop();

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        thumbnails = [];
        detail = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            thumbnails* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            thumbnailer(i);
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("portfolio.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
        prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
        nextImage();
    }
};
Key.addListener(listen);
prev_btn.onRelease = function() {
    prevImage();
};
next_btn.onRelease = function() {
    nextImage();
};
/////////////////////////////////////
closeup._alpha = 0;
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 += 5;
        }
    }
};
function nextImage() {
    if (p<(total-1)) {
        p++;
        if (loaded == filesize) {
            picture._alpha = 0;
            picture.loadMovie(image[p],1);
            desc_txt.text = caption[p];
            closeup.unloadMovie(detail[p],1);
            picture_num();
        }
    
    }else if (p=(total-1)) {
        firstImage();
    }
        
}
function prevImage() {
    if (p>0) {
        p--;
        picture._alpha = 0;
        picture.loadMovie(image[p],1);
        desc_txt.text = caption[p];
        closeup.unloadMovie(detail[p],1);

        picture_num();
    }else if (p==0) {

        picture._alpha = 0;
        picture.loadMovie(image[(total-1)],1);
        desc_txt.text = caption[(total-1)];
        closeup.unloadMovie(detail[(total-1)],1);

        picture_num();
    }
        
}
function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0],1);
        desc_txt.text = caption[0];
        picture_num();
    }
}
function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
}

function showDetail() {

    picture._visible = false;
    closeup.loadMovie(detail[p],1);
    if (closeup._alpha<100) {
        closeup._alpha += 100;
    } else {
        if (closeup._alpha>0) {
            closeup._alpha -= 100;
            picture._visible = true;
        }
    }
}

detail_btn.onRelease = function() {
    showDetail();
};

var x_counter:Number = 0;
var y_counter:Number = 0;
var columns:Number = 10;

var my_thumb_width:Number = 116;
var my_thumb_height:Number = 116;


function thumbnailer(k) {

    thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_mc.getNextHighestDepth());
    tlistener = new Object();
    tlistener.onLoadInit = function(target_mc) {

        target_mc.name = i;
        target_mc._x = (my_thumb_width+10)*x_counter;
        target_mc._y = (my_thumb_height+10)*y_counter;
        if (x_counter+1 < columns) {
            x_counter++;
        } else {
            x_counter = 0;
            y_counter++;
        }
        target_mc.pictureValue = k;
        target_mc.onRelease = function() {

            p = this.pictureValue-1;
            nextImage();

        };
        target_mc.onRollOver = function() {

            this._alpha = 100;

        };
        target_mc.onRollOut = function() {

            this._alpha = 100;


        };

    };
    image_mcl = new MovieClipLoader();
    image_mcl.addListener(tlistener);
    image_mcl.loadClip(thumbnails[k],"thumbnail_mc.t"+k);
}