# Flash 8 XML Slideshow Help!

**URL:** https://forum.kirupa.com/t/flash-8-xml-slideshow-help/249180
**Category:** Uncategorized
**Created:** [January 16, 2008, 6:35am UTC](https://forum.kirupa.com/t/flash-8-xml-slideshow-help/249180 "2008-01-16T06:35:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jwiz007](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jwiz007](https://forum.kirupa.com/u/jwiz007)
#### Post date: [January 16, 2008, 6:35am UTC](https://forum.kirupa.com/t/flash-8-xml-slideshow-help/249180/1 "2008-01-16T06:35:56Z")

</div>

Hello,

I have a slideshow that I had purchased as a template but I would like to add a slideshow function to it. Right now, it is pulling from an xml file and you can only click “next”, “previous” or on the thumbnails to view the photos. I would also like the “next” and “previous” buttons to be outside of the image. I am new to actionscript so I am having trouble writing the function that will display the images as a slideshow. I have included the code below.

Here is the code on the first frame inside the gallery\_mc movieclip:

stageW = 800;  
stageH = 600;  
bgX = bg.\_x;  
bgY = bg.\_y;  
menu\_mc.bgX = menu\_mc.bg.\_x;  
menu\_mcX = menu\_mc.\_x;  
menu\_mcY = menu\_mc.\_y;  
stageListener = new Object();  
Stage.addListener(stageListener);  
alignObjects = function () {  
bg.\_x = bgX-(Stage.width-stageW)/2;  
bg.\_y = bgY-(Stage.height-stageH)/2;  
bg.\_width = Stage.width;  
bg.\_height = Stage.height;  
menu\_mc.\_x = 0.0;  
menu\_mc.\_y = -225.0;  
menu\_mc.bg.\_x = menu\_mc.bgX-(Stage.width-stageW)/2;  
menu\_mc.bg.\_width = Stage.width;  
};  
stageListener.onResize = function() {  
alignObjects();  
};  
alignObjects();  
//Load XML Data  
function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
colour = [];  
thumb = [];  
copy\_txt = []  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
colour\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
thumb\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
copy\_txt\* = xmlNode.childNodes\*.childNodes[3].firstChild.nodeValue;  
gotoAndStop(2);  
}  
} else {  
msg.text = “Error loading XML”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“content.xml”);  
stop();

Here is the code on teh second frame in the gallery\_mc movieclip:

////////////Initial Settings////////////  
//Set border size here  
border = 15;  
//Set your stage width & height here  
stageW = 800;  
stageH = 600;  
//Set initial size of white block on first image load here  
bg\_mc.bg.\_width = 200;  
bg\_mc.bg.\_height = 200;  
//Set number of thumbs to be displayed  
minThumbs = 15;  
//Set spacing between thumbs  
thumbSpacing = 6;  
////////////Initial Values////////////  
page = 0;  
info\_mc.\_alpha = 0;  
info\_mc.destAlpha = 0;  
bttnNext.\_visible = false;  
bttnPrev.\_visible = false;  
info\_bttn.\_visible = false;  
////////////Functions: Buttons/////////////  
bg\_mc.bg.bttnNext.onRelease = function() {  
nextPage();  
};  
bg\_mc.bg.bttnNext.onRollOver = function() {  
bttnNext.\_visible = true;  
};  
bg\_mc.bg.bttnNext.onRollOut = function() {  
bttnNext.\_visible = false;  
};  
bg\_mc.bg.bttnNext.onDragOut = function() {  
bttnNext.\_visible = false;  
};  
bg\_mc.bg.bttnPrev.onRelease = function() {  
prevPage();  
};  
bg\_mc.bg.bttnPrev.onRollOver = function() {  
bttnPrev.\_visible = true;  
};  
bg\_mc.bg.bttnPrev.onRollOut = function() {  
bttnPrev.\_visible = false;  
};  
bg\_mc.bg.bttnPrev.onDragOut = function() {  
bttnPrev.\_visible = false;  
};  
info\_bttn.bttn.onRollOver = function() {  
info\_mc.destAlpha = 100;  
};  
info\_bttn.bttn.onRollOut = function() {  
info\_mc.destAlpha = 0;  
};  
info\_bttn.bttn.onDragOut = function() {  
info\_mc.destAlpha = 0;  
};  
////////////Functions: Page Navigation/////////////  
function nextPage() {  
if (page\<(total-1)) {  
if (this.menu\_mc.thumb\_menu.\_x\>this.menu\_mc.thumb\_menu.destX-0.5 && this.menu\_mc.thumb\_menu.\_x\<this.menu\_mc.thumb\_menu.destX+0.5) {  
if (this.menu\_mc.thumb\_menu.\_x\>(this.menu\_mc.thumb\_menu.originX-(this.menu\_mc.thumb\_menu.\_width-(this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing)_(minThumbs+1))-5)) {  
this.menu\_mc.thumb\_menu.destX -= (this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing);  
}  
holder.\_alpha = -100;  
info\_mc.\_alpha = 0;  
page++;  
loadMovie(image[page], holder);  
pageNum();  
}  
}  
}  
function prevPage() {  
if (page\>0) {  
if (this.menu\_mc.thumb\_menu.\_x\>this.menu\_mc.thumb\_menu.destX-0.5 && this.menu\_mc.thumb\_menu.\_x\<this.menu\_mc.thumb\_menu.destX+0.5) {  
if (this.menu\_mc.thumb\_menu.\_x\<this.menu\_mc.thumb\_menu.originX-5) {  
this.menu\_mc.thumb\_menu.destX += (this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing);  
}  
holder.\_alpha = -100;  
info\_mc.\_alpha = 0;  
page–;  
loadMovie(image[page], holder);  
pageNum();  
}  
}  
}  
function firstPage() {  
holder.\_alpha = -100;  
info\_mc.\_alpha = 0;  
loadMovie(image[page], holder);  
pageNum();  
}  
function pageNum() {  
bg.newHEX = colour[page];  
info\_mc.txt.text = copy\_txt[page];  
}  
\_global.thumbClick = function(object) {  
page = object.ID;  
holder.\_alpha = -100;  
loadMovie(image[page], holder);  
pageNum();  
};  
firstPage();  
alignPic();  
////////////Alignment of objects on stage resize////////////  
function alignPic() {  
destWidth = holder.\_width;  
destHeight = holder.\_height;  
holder.\_x = (stageW-holder.\_width)/2;  
holder.\_y = (stageH-holder.\_height-menu\_mc.\_height)/2;  
bg\_mc.bg.\_width += (destWidth+border-bg\_mc.bg.\_width)/5;  
bg\_mc.bg.\_height += (destHeight+border-bg\_mc.bg.\_height)/5;  
bg\_mc.bg.\_x = holder.\_x;  
bg\_mc.bg.\_y = holder.\_y;  
bg\_mc.\_x = holder.\_width/2;  
bg\_mc.\_y = holder.\_height/2;  
bttnNext.\_y = holder.\_y+(holder.\_height-bttnNext.\_height)/2;  
bttnNext.\_x = bg\_mc.\_width+(stageW-bg\_mc.\_width)/2-bttnNext.\_width-border/2;  
bttnPrev.\_y = holder.\_y+(holder.\_height-bttnPrev.\_height)/2;  
bttnPrev.\_x = (stageW-bg\_mc.\_width)/2+bttnPrev.\_width+border/2;  
preloader.\_x = holder.\_x+holder.\_width/2;  
preloader.\_y = holder.\_y+holder.\_height/2;  
info\_bttn.\_x = preloader.\_x;  
info\_bttn.\_y = preloader.\_y;  
info\_mc.\_x = preloader.\_x;  
info\_mc.\_y = holder.\_y+holder.\_height;  
info\_mc.bg.\_width = holder.\_width;  
info\_mc.txt.\_width = info\_mc.bg.\_width;  
info\_mc.txt.\_x = info\_mc.bg.\_x-info\_mc.bg.\_width/2;  
}  
////////////Build Image Gallery based on XML Data////////////  
for (i=0; i\<total; ++i) {  
this.menu\_mc.thumb\_menu.thumb\_mc.duplicateMovieClip(“thumb\_mc”+i, i);  
this.menu\_mc.thumb\_menu.thumb\_mc.\_visible = false;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].ID = i;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].\_x = (this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing)i;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].holder.loadMovie(thumb);  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].txt = txt_;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].destX = this.menu\_mc.thumb\_menu[“thumb\_mc”+i].\_x;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].\_alpha = 0;  
this.menu\_mc.thumb\_menu.\_x = this.menu\_mc.thumb\_menu.originX=(stageW-(this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing)\*minThumbs)/2;  
this.menu\_mc.mask\_mc.\_width = (this.menu\_mc.thumb\_menu.thumb\_mc.\_width+thumbSpacing)\*minThumbs;  
this.menu\_mc.mask\_mc.\_x = this.menu\_mc.thumb\_menu.\_x;  
this.menu\_mc.bttnPrev.\_x = this.menu\_mc.mask\_mc.\_x-thumbSpacing;  
this.menu\_mc.bttnNext.\_x = this.menu\_mc.mask\_mc.\_x+this.menu\_mc.mask\_mc.\_width;  
this.menu\_mc.thumb\_menu[“thumb\_mc”+i].onEnterFrame = function() {  
if (page == this.ID) {  
this.gotoAndStop(21);  
} else {  
if (this.\_currentframe == 21) {  
this.play();  
}  
}  
if (this.isLoaded && this.\_alpha\<100) {  
this.\_alpha += 10;  
}  
};  
}  
////////////Thumnail menu and preloader script////////////  
this.menu\_mc.thumb\_menu.destX = this.menu\_mc.thumb\_menu.\_x;  
onEnterFrame = function () {  
this.menu\_mc.thumb\_menu.\_x += (this.menu\_mc.thumb\_menu.destX-this.menu\_mc.thumb\_menu.\_x)/3;  
loaded = holder.getBytesLoaded();  
filesize = holder.getBytesTotal();  
if (filesize\>100) {  
percentage = Math.round((loaded/filesize)\*100);  
preloader.percentageTxt = percentage;  
if (isNaN(percentage) or percentage == 0) {  
percentage = 0;  
preloader.left.half.\_rotation = 0;  
preloader.right.half.\_rotation = 0;  
picLoaded = false;  
} else if (percentage\<=50 && percentage\>0) {  
preloader.left.half.\_rotation = 0;  
preloader.right.half.\_rotation = (360/100)_percentage;  
picLoaded = false;  
} else if (percentage\>50 && percentage\<100) {  
preloader.left.half.\_rotation = (360/100)_(percentage-50);  
preloader.right.half.\_rotation = 180;  
picLoaded = false;  
} else if (filesize == loaded) {  
info\_bttn.\_visible = true;  
preloader.left.half.\_rotation = 180;  
preloader.right.half.\_rotation = 180;  
alignPic();  
if (bg\_mc.bg.\_width\>destWidth) {  
info\_mc.\_alpha += (info\_mc.destAlpha-info\_mc.\_alpha)/5;  
if (holder.\_alpha\<100) {  
holder.\_alpha += 5;  
}  
} else {  
info\_mc.\_alpha = 0;  
info\_mc.\_destAlpha = 0;  
}  
}  
}  
};  
stop();

I just need to add a function that will loop through the xml file and automatically start the slideshow onLoad. Any help would be great!

Thank you.
