Hi everyone. I’m trying to create a flash document that just does a slideshow through the images, but the image paths are all in an external xml file (this is because we are going to randomize that xml file on the fly with server scripting) and I want a preloader that loads the swf and all 5 of the external images that are in the document. The way I was able to get it to work is to use this script to load the XML doc and the images:
function loadXML(loaded) {
if (loaded) {
//pulls all data from the xml file
xmlNode = this.firstChild;
path = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
path* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
}
changeImage();
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“flashbanners/homebanner.xml”);
function changeImage() {
container1.loadMovie(path[0], 1);
container2.loadMovie(path[1], 1);
container3.loadMovie(path[2], 1);
container4.loadMovie(path[3], 1);
container5.loadMovie(path[4], 1);
}
And then I call that changeImage(); function on each keyframe when a new image container appears. It’s the only way I could figure it out to get it to work this way, although I’m sure there is a better one. Here is the preload script I was trying:
preloader._visible = false;
this.onEnterFrame = function() {
//finds out how much of the clip is loaded
filesize = Math.round(getBytesTotal());
loaded = Math.round(getBytesLoaded());
//starts the preloader if everything is not loaded yet
if (loaded != filesize) {
preloader._visible = true;
//preload bar length
preloader.preload_bar._xscale = 100*loaded/filesize;
//percentage number
loaded_bytes = Math.round(getBytesLoaded());
loaded_total = Math.round(getBytesTotal());
total_percent = (loaded_bytes/loaded_total)*100;
preloader.loaded_text = Math.round(total_percent);
} else {
preloader._visible = false;
}
};
So, is it even possible for a preloader to do that? I got one to work that preloaded each image as it came up, but that’s not the solution I’d like. I appreciate anyone’s input!