# Slideshow / XML Gallery Help!

**URL:** <https://forum.kirupa.com/t/slideshow-xml-gallery-help/212600>\
**Category:** flash\
**Created:** [January 12, 2007, 12:53pm UTC](https://forum.kirupa.com/t/slideshow-xml-gallery-help/212600 "2007-01-12T12:53:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wavygravy](https://avatars.discourse-cdn.com/v4/letter/w/73ab20/32.png) [@wavygravy](https://forum.kirupa.com/u/wavygravy)\
**Post date:** [January 12, 2007, 12:53pm UTC](https://forum.kirupa.com/t/slideshow-xml-gallery-help/212600/1 "2007-01-12T12:53:14Z")

</div>

Hi there, this is my first post! I am not a programmer, but have managed to combine the slideshow, image gallery and hover features of the provided scripts to create a slideshow that you can control with the previous and next buttons. I have also been able to connect it to an access database so you can control the images / info through Content Management console . . . . . once this has been sorted I will post the code here, if its any use to anyone.

Here is the script!

delay = 5000;  
//-----------------------  
function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
description = [];  
url = [];  
link = [];  
caption = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
url\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
link\* = xmlNode.childNodes\*.childNodes[3].firstChild.nodeValue;  
caption\* = xmlNode.childNodes\*.childNodes[4].firstChild.nodeValue;

```
    }
    firstImage();
} else {
    content = "file not loaded!";
}

```

}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images\_sort.asp”);  
// ///////////////////////////////////  
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();  
};  
// ///////////////////////////////////  
p = 0;  
spacing = 10;  
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;  
if (Math.round(filesize/loaded) == 1 &&

picture.\_width != 0 && picture.\_height != 0) {  
var w = picture.\_width+spacing, h =

picture.\_height+spacing;  
border.resizeMe(w, h, id);

```
    }
}
};
//getURL statement
picture.onRelease = function() {
    getURL(link[p], "_blank");
};
//
//Hover Caption
picture.onRollOver = function() { 
captionFN(true, caption[p], this); 
this.onRollOut = function() { 
captionFN(false); 

```

};  
};  
//  
};  
function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
link\_txt.text = url[p];  
cap.desc.text = caption[p];  
picture\_num();  
slideshow();  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
link\_txt.text = url[p];  
cap.desc.text = caption[p];  
slideshow();  
picture\_num();

```
}

```

}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
desc\_txt.text = description[0];  
link\_txt.text = url[0];  
cap.desc.text = caption[0];  
slideshow();  
picture\_num();  
}  
}  
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)) {  
p = 0;  
firstImage();  
} else {  
nextImage();  
}  
}

};

//Hover Caption Function  
captionFN = function (showCaption, captionText, bName) {  
if (showCaption) {  
\_root.createEmptyMovieClip(“hoverCaption”, this.getNextHighestDepth());  
cap.desc.text = captionText;  
cap.\_width = 5\*cap.desc.text.length;  
cap.\_alpha = 100;  
//  
if ((bName.\_width+bName.\_x+cap.\_width)\>Stage.width) {  
xo = -2-cap.\_width;  
yo = -17;  
} else {  
xo = 2;  
yo = -17;  
}  
hoverCaption.onEnterFrame = function() {  
cap.\_x = \_root.\_xmouse+xo+10;  
cap.\_y = \_root.\_ymouse+yo;  
cap.\_visible = true;  
};  
} else {  
delete hoverCaption.onEnterFrame;  
cap.\_visible = false;  
}  
};

It works great, apart from when I interupt the slideshow, the image selection goes mental - it starts ignoring where it is and what the interval is set to.

Has anyone alny ideas . . . . . .!

Thanks in advance

Pete
