Xml gallery reloads content - help needed w AS!

Hi there,

I created a dynamic gallery based on a Kirupa tutorial (http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm), and modified it to hide the texts unless clicked into view from a button. I now have the button & text animation on the main timeline in five frames, with the “hidden” dynamic text visible in the third frame.

First I had a problem with loading the texts into view when clicking the button, but managed to solve it by putting the same code in the 3rd frame as there’s in the first one. So now it basically works, but if you click the texts “on” and “off” and “on” again, the movie jumps back into the first image (and text). I guess it reloads the xml, since turning the texts on at the 1st image fades the picture in again.

Any ideas on how to fix this? I tried deleting some parts of the code (in frame 3) but can’t figure out where the problem is. The code in frame 3 now looks like this:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“images_1.xml”);
/////////////////////////////////////
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
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 += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture.loadMovie(image[p]);
desc_txt.text = description[p];
picture_num();
}
}
else if (p==(total-1)) {
_root.gotoAndStop(7)
}
}
function prevImage() {
if (p>0) {
p–;
picture.loadMovie(image[p]);
desc_txt.text = description[p];
picture_num();
}
}

stop();

Thanks for your time!