# Need help with XML gallery

**URL:** <https://forum.kirupa.com/t/need-help-with-xml-gallery/216998>\
**Category:** flash\
**Created:** [February 22, 2007, 6:34am UTC](https://forum.kirupa.com/t/need-help-with-xml-gallery/216998 "2007-02-22T06:34:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![everlastingfuel](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/everlastingfuel/32/3337_2.png) [@everlastingfuel](https://forum.kirupa.com/u/everlastingfuel)\
**Post date:** [February 22, 2007, 6:34am UTC](https://forum.kirupa.com/t/need-help-with-xml-gallery/216998/1 "2007-02-22T06:34:17Z")

</div>

Need help with XML Photo gallery/Slideshow  
Dear forumers,  
I need help with creating a automatic slideshow with control buttons.  
Have browsed through Kirupa’s tutorials and have made references to the following 2 tutorials  
[http://www.kirupa.com/developer/mx2004/xml\_flash\_photogallery.htm](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm)  
[http://www.kirupa.com/developer/mx2004/xml\_slideshow.htm](http://www.kirupa.com/developer/mx2004/xml_slideshow.htm)  
I am trying to combine the codes for these 2 tutorials so that I can have the images cycle automatically but at the same time with control buttons  
like “back”, “next” and “pause”.  
Please see below for my attempt…  
stop();  
delay = 3000;  
function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
image2 = [];  
image3 = [];  
description = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
image2\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
image3\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[3].firstChild.nodeValue;  
}  
firstImage();  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);  
/////////////////////////////////////  
Key.addListener(listen);  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};  
next\_btn.onRelease = function() {  
nextImage();  
};  
/////////////////////////////////////  
//------------ preloader  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
filesize = picture2.getBytesTotal();  
loaded = picture2.getBytesLoaded();  
filesize = picture3.getBytesTotal();  
loaded = picture3.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.preload\_bar.\_xscale = 100_loaded/filesize;  
preloader2.preload\_bar.\_xscale = 100_loaded/filesize;  
preloader3.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (picture.\_alpha\<100) {  
picture.\_alpha += 10;  
}

preloader2.\_visible = false;  
if (picture2.\_alpha\<100) {  
picture2.\_alpha += 10;  
}  
preloader3.\_visible = false;  
if (picture3.\_alpha\<100) {  
picture3.\_alpha += 10;  
}

}  
};  
//------------ preloader  
function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
picture2.\_alpha = 0;  
picture2.loadMovie(image2[p], 1);  
picture3.\_alpha = 0;  
picture3.loadMovie(image3[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
slideshow();  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
picture2.loadMovie(image2[p], 1);  
picture3.loadMovie(image3[p], 1);  
desc\_txt.text = description[p];  
//picture\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
picture2.loadMovie(image2[0], 1);  
picture3.loadMovie(image3[0], 1);  
desc\_txt.text = description[0];  
//picture\_num();  
slideshow();  
}  
}  
/\*  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}  
\*/  
//-- timer thing  
function slideshow() {  
myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1)) {  
p = 0;  
firstImage();  
} else {  
nextImage();  
}  
}  
//function  
}

## Issue 1

## I tried to assign the functions nextImage(); and prevImage(); into my ‘next’ and ‘back’ buttons respectively The automated slideshow works fine but there seems to be a bug somewhere whereby ‘next’ brings me to the next screen but right after that the other screens will jump about in wrong sequences. I have no wonder what is wrong as i am a beginner in AS.

## Issue 2

I require a ‘pause’ button in my slideshow as well  
Is anyone kind enough to help me write a function that I can assign to my ‘pause’ button to make the slideshow pause?  
I see a pause\_slideshow() within the slideshow() function but I do not really understand the codes, that is why I am having so much  
difficulty.  
Please help me! Thanks in advance :hugegrin:
