# Xml auto gallery question

**URL:** <https://forum.kirupa.com/t/xml-auto-gallery-question/254976>\
**Category:** flash\
**Created:** [March 17, 2008, 9:25pm UTC](https://forum.kirupa.com/t/xml-auto-gallery-question/254976 "2008-03-17T21:25:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![max999](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@max999](https://forum.kirupa.com/u/max999)\
**Post date:** [March 17, 2008, 9:25pm UTC](https://forum.kirupa.com/t/xml-auto-gallery-question/254976/1 "2008-03-17T21:25:49Z")

</div>

Hi i have this photo gallery that automatically loads and play external jpgs via XML, i wanted to add a button for stop, next and prev…how do i do it?  
Thanks a lot  
This is the code:  
var delay:Number = 2500;  
var init:Boolean = false;

var top:MovieClip = picture;  
var bot:MovieClip = picture2;

//-----------------------  
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”);  
p = 0;

function fadeIn() {  
//swap();  
onEnterFrame = function() {  
filesize = top.getBytesTotal();  
loaded = top.getBytesLoaded();  
if (loaded != filesize) {  
preloader.\_visible = true;  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;  
if (top.\_alpha \< 100) {  
top.\_alpha +=5;  
}else{  
delete onEnterFrame;  
slideshow();  
}  
}  
};  
};

function fadeOut() {  
onEnterFrame = function() {  
if (top.\_alpha \> 5) {  
top.\_alpha -=5;  
}else{  
top.\_alpha = 0;  
delete onEnterFrame;  
nextImage();  
}  
};  
};

function nextImage() {  
if (p\<(total-1)) {  
p++;  
top.\_alpha = 0;  
top.loadMovie(image[p]);  
desc\_txt.text = description[p];  
picture\_num();  
fadeIn();  
}  
};

function firstImage() {  
init = true;  
top.\_alpha = 0;  
top.loadMovie(image[0]);  
desc\_txt.text = description[0];  
picture\_num();  
fadeIn();  
};

function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
};

function slideshow() {  
myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1) && !init) {  
p = 0;  
firstImage();  
} else if (p == (total-1) && init) {  
p = -1;  
swap();  
}else{  
swap();  
}  
}  
};

function swap(){  
var t = top;  
top.swapDepths(bot);  
top = bot;  
bot = t;  
nextImage();  
}
