# XML auto crossfading gallery..stop looping after one round?

**URL:** <https://forum.kirupa.com/t/xml-auto-crossfading-gallery-stop-looping-after-one-round/289334>\
**Category:** flash\
**Created:** [May 29, 2009, 2:42am UTC](https://forum.kirupa.com/t/xml-auto-crossfading-gallery-stop-looping-after-one-round/289334 "2009-05-29T02:42:54Z")\
**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:** [May 29, 2009, 2:42am UTC](https://forum.kirupa.com/t/xml-auto-crossfading-gallery-stop-looping-after-one-round/289334/1 "2009-05-29T02:42:54Z")

</div>

I have this code for an auto slideshow(supposed to be with thumbs but i am not using them), how do i stop from looping after all the pics run once?  
Thanks a lot  
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();  
}
