# Using xml to display photos / captions

**URL:** <https://forum.kirupa.com/t/using-xml-to-display-photos-captions/221252>\
**Category:** Uncategorized\
**Created:** [April 2, 2007, 9:24pm UTC](https://forum.kirupa.com/t/using-xml-to-display-photos-captions/221252 "2007-04-02T21:24:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhdc](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@jhdc](https://forum.kirupa.com/u/jhdc)\
**Post date:** [April 2, 2007, 9:24pm UTC](https://forum.kirupa.com/t/using-xml-to-display-photos-captions/221252/1 "2007-04-02T21:24:39Z")

</div>

Hi,  
I used the Kirupa tutorial to set up a photo slideshow using arrows to advance photos.  
Now I want to have another button with photos. Right now I have a button “number 1” that activates my photo gallery. How do I set up button “number 2” to go to another section of photos. Do I need to duplicate the entire code?  
Thanks. Below is my code:

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.xml”);

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(“images2.xml”);  
/////////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
Key.addListener(listen);  
arrow\_lt\_mc.onRelease = function() {  
prevImage();  
};  
arrow\_rt\_mc.onRelease = function() {  
nextImage();  
};  
p = 0;  
//////////////////////////////////////////////////////////////////////  
//  
// this code will turn off the preloader using the object listener method  
myPicLoader.onLoad = function(success) {  
if (success) {  
preloader.\_visible = false;  
}  
};  
// this will set the preloader bar to the percentage of the loaded image  
myPicLoader.onProgress = function(percent) {  
preloader.preload\_bar.\_xscale = percent;  
};  
// end preloading  
//  
///////////////////////////////////////////////////////////////////////  
function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
myPicLoader.contentPath = image[p];  
preloader.\_visible = true;  
desc\_txt.text = description[p];  
myPicLoader\_num();  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
myPicLoader.contentPath = image[p];  
preloader.\_visible = true;  
desc\_txt.text = description[p];  
myPicLoader\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
myPicLoader.contentPath = image[0];  
preloader.\_visible = true;  
desc\_txt.text = description[0];  
myPicLoader\_num();  
}  
}  
function myPicLoader\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}
