# Updated xml slideshow code - final tweak needed

**URL:** <https://forum.kirupa.com/t/updated-xml-slideshow-code-final-tweak-needed/181919>\
**Category:** Uncategorized\
**Created:** [March 14, 2006, 8:52am UTC](https://forum.kirupa.com/t/updated-xml-slideshow-code-final-tweak-needed/181919 "2006-03-14T08:52:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yabai](https://avatars.discourse-cdn.com/v4/letter/y/958977/32.png) [@yabai](https://forum.kirupa.com/u/yabai)\
**Post date:** [March 14, 2006, 8:52am UTC](https://forum.kirupa.com/t/updated-xml-slideshow-code-final-tweak-needed/181919/1 "2006-03-14T08:52:47Z")

</div>

hi everyone.

i have updated the xml photo gallery with slideshow.

- I now have a stop slideshow button.
- A slideshow button simply calls nextImage() and starts the slideshow again.
- I also have a previous and next buttons that don’t start the slideshow function.

Here is my question. when using the slideshow or the next button it gets to the last image and stops. Can anyone show me the ‘if’ statements that would go back to image1 and allow both of these functions to continue.

Below is the code i have. i also managed to get the images to pop into a new window, centred, with the window determined by the image dimensions. I am chuffed about that but am just stuck on the ‘if’ statements.

Cheers for any help.

* * *

var\_img = “”;  
delay = 6000;  
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”);

// ///////////////////////////////////  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
delay = 6000;  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
delay = 6000;  
}  
};  
Key.addListener(listen);

previous\_btn.onRelease = function() {  
prevImage();  
};

next\_btn.onRelease = function() {  
nextImage1();  
};  
stop\_btn.onRelease = function() {  
clearInterval(myInterval);  
};

slideshow\_btn.onRelease = function() {  
nextImage();  
};

\_root.openWinCentre = function(url, thewin, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {  
var bo\_var = \_root.var\_img;  
//CHANGE  
trace(bo\_var);  
var bo\_img = bo\_var.substr(0, -10);  
trace(bo\_img);  
url = bo\_img+"\_big.htm";  
trace(url);  
//myImage = bo\_img+"\_big.jpg";  
getURL(“javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open(’”+url+"’,‘thewin’,’"+“width=”+w+",height="+h+",toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+",scrollbars="+scrollbars+",resizable="+resizable+",top=’+((screen.height/2)-("+h/2+"))+’,left=’+((screen.width/2)-("+w/2+"))+’"+"’)}else{myWin.focus();};void(0);");  
};

p = 0;  
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 nextImage1() {  
clearInterval(myInterval);  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
\_root.var\_img = image[p];  
}  
}  
}

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
\_root.var\_img = image[p];  
slideshow();  
}  
}  
}

function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
picture\_num();  
\_root.var\_img = image[p];  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
picture\_num();  
\_root.var\_img = image[p];  
slideshow();  
}  
}

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

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

---

<div class="post-metadata">

**Author:** ![rmcnaugh](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rmcnaugh](https://forum.kirupa.com/u/rmcnaugh)\
**Post date:** [March 31, 2006, 6:18pm UTC](https://forum.kirupa.com/t/updated-xml-slideshow-code-final-tweak-needed/181919/2 "2006-03-31T18:18:36Z")

</div>

instead of this.

slideshow\_btn.onRelease = function() {  
nextImage();  
};

try this

slideshow\_btn.onRelease = function() {  
slideshow();  
};

---

<div class="post-metadata">

**Author:** ![gallerykid](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@gallerykid](https://forum.kirupa.com/u/gallerykid)\
**Post date:** [April 4, 2006, 2:48am UTC](https://forum.kirupa.com/t/updated-xml-slideshow-code-final-tweak-needed/181919/3 "2006-04-04T02:48:04Z")

</div>

I tried the XML Photogallery - Slideshow and love it! Sweet Code. Anyone know how to add links to the photos in the XML files. I’m building a portfolio and need to link to several different pages from different slides.
