Help with XML GALLERY

**Can anyone help me out,with my XML Gallery?

The problem is if I press the buttons in a sequential manner…the data loads fine…but If i pres it randomly choosing a button…the data doesnt loads according to the button…The problem lies with the Variable “p”.Please have a look.I would be very much grateful…to every one who would help me out.**

Here is the Actions on Frame-1 :

var caption:Array = new Array();
var descriptions:Array = new Array();
var thumbs:Array = new Array();
var images:Array = new Array();
var mc:Array = new Array();
var ids:Array = new Array();
function loadXML(loaded) {
if (loaded) {
trace(“Loaded”);
xmlNode = this.firstChild;
lengths = xmlNode.childNodes.length-1;
trace(“XML LENGTH =”+lengths);

    // Loop

    for (i=0; i<=lengths; i++) {
        ids* = i;
        trace("ID="+ids*);

        // Create Movie Clips
        var xpos = 250;
        var ypos = 124;
        var ychange = ypos+18*i;
        mc* = _root.attachMovie("clip", "clip"+i, i, {_x:pos, _y:ychange});

        //_root["clip"+i].cap = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
        //_level0.loaders.loadMovie(thumbs[0],100);

        //Duplicate Movie Clip
        //mc* = _root.clip.duplicateMovieClip("clip"+i, i, {_x:pos, _y:ychange+84});
        //mc*._y=(_root.clip._y)+84;

        caption* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
        _root["clip"+i].cap = caption*;
        trace("cap="+caption*);



        descriptions* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;

        //trace("des="+description*);
        thumbs* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
        trace("thumb="+thumbs*);
        images* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
        trace("images="+images*);
        // trace(xmlNode.childNodes[0].childNodes[0].firstChild.nodeValue); - Output - WAR TROLL
        //trace(xmlNode.childNodes[0].childNodes[1].firstChild.nodeValue);  - Output - Description

    }

    firstImage();

} else {
    trace("Not Loaded");
}

}

var xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“data.xml”);
var p = 0;
this.onEnterFrame = function() {

filesize = _root.shows.loadimage.getBytesTotal();
loaded = _root.shows.loadimage.getBytesLoaded();

if (loaded!=filesize) {
    _root.attachMovie("loadbar","loadbar1",200,{_x:400, _y:287});
    _root.loadbar1._xscale = 100*loaded/filesize;
    _root.shows.wait.gotoAndPlay(2);

} else {
    removeMovieClip(_root.loadbar1);
    _root.shows.wait.gotoAndStop(1);

}

};
function firstImage() {
trace(“desc=”+_level0.descriptions[0]);
_root.shows.loadimage.loadMovie(images[0],0);
_level0.shows.descri = _level0.descriptions[0];

removeMovieClip(_level0.loadbar1);

}
function clickImage() {
p++;
if (p<(_level0.lengths-1)) {
_root.shows.loadimage.loadMovie(_level0.images[p],0);
_root.shows.descri = _level0.descriptions[p];
trace(“p=”+p);

}

}
function nextImage() {
if (p>0) {
p–;
_root.shows.loadimage.loadMovie(_level0.images[p],p);
_root.shows.loadimage.descr = _level0.descriptions[p];
trace(“p=”+p);
}
}

You can have the FLA file here - http://www.flashrockers.net/main.fla
You can have the XML file here - http://www.flashrockers.net/data.xml

:sonic: Flashrockers