# Preloading XML Slideshow

**URL:** https://forum.kirupa.com/t/preloading-xml-slideshow/196843
**Category:** flash
**Created:** [August 11, 2006, 10:57am UTC](https://forum.kirupa.com/t/preloading-xml-slideshow/196843 "2006-08-11T10:57:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wayniep00p](https://avatars.discourse-cdn.com/v4/letter/w/839c29/32.png) [@wayniep00p](https://forum.kirupa.com/u/wayniep00p)
#### Post date: [August 11, 2006, 10:57am UTC](https://forum.kirupa.com/t/preloading-xml-slideshow/196843/1 "2006-08-11T10:57:36Z")

</div>

Hello,

I really need your guys’ help on this one. I have this XML based slide show for Flash that works fairly well (based on the [XML slideshow tutorial on the site). The slide show currently preloads the images between the slides. It works pretty well on a broadband connection since the load time doesn’t seem to get in the way of viewing the pictures. However, it gets pretty annoying to see the loading screen between each image. I was wondering can I tell flash to preload all the images on the first slide before starting the slide show? An example of the code in action is at [URL=“http://andygoldman.com/busanutenterprises\_css/spaceprogram/slideshow.html”]http://andygoldman.com/busanutenterprises\_css/spaceprogram/slideshow.html](http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm) .

Here is the actionscript that currently drives the slide show:

(“picture” is the name of the movie clip that the images load into)

[COLOR=Gray]function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
name = [];  
dimensions = [];  
addinfo = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firs[/COLOR][COLOR=Gray]tChild.nod[/COLOR][COLOR=Gray]eValue;  
name\* = xmlNode.childNodes\*.childNodes[1].firs[/COLOR][COLOR=Gray]tChild.nod[/COLOR][COLOR=Gray]eValue;  
dimensions\* = xmlNode.childNodes\*.childNodes[2].firs[/COLOR][COLOR=Gray]tChild.nod[/COLOR][COLOR=Gray]eValue;  
addinfo\* = xmlNode.childNodes\*.childNodes[3].firs[/COLOR][COLOR=Gray]tChild.nod[/COLOR][COLOR=Gray]eValue;  
}  
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) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};  
next\_btn.onRelease = function() {  
nextImage();  
};  
/////////////////////////////////////  
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 += 5;  
}  
}  
};

function nextImage() {  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
name\_txt.text = name[p];  
dimensions\_txt.text = dimensions[p];  
addinfo\_txt.text = addinfo[p];  
picture\_num();  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
name\_txt.text = name[p];  
dimensions\_txt.text = dimensions[p];  
addinfo\_txt.text = addinfo[p];  
picture\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
name\_txt.text = name[0];  
dimensions\_txt.text = dimensions[0];  
addinfo\_txt.text = addinfo[0];  
picture\_num();  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" of "+total;  
}

stop();[/COLOR]
