Hi there,
I’m currently making a xml driven photo gallery. The first stage is loading in the thumbnails, each thumbnail will preload individually. I pretty close to acheiving this except my current script only loads in the first jpeg. I have tried everything and I jsut can’t find a problem. Anyway my code is below if anyone gets a chance to look. Sorry its a bit hefty. I think the problem is with the ThumbLoadingEnterFrame and LoadNextThumb functions.
Any help much appreciated :thumb:
Cheers
count = 0;
var thumbImage = new Array();
var thumbClip = new Array();
var jpegImage = new Array();
function ThumbLoadingEnterFrame() {
var lod = this.loader_mc.getBytesLoaded();
var tot = this.loader_mc.getBytesTotal();
if (lod && tot) {
var percent_loaded = lod/tot;
this.progress_mc._xscale = 100*percent_loaded;
if (percent_loaded == 1) {
LoadNextThumb();
delete this.onEnterFrame;
}
}
}
function LoadNextThumb() {
//trace(thumbImage.length);
if (count<thumbImage.length) {
var imgURL = thumbImage[count];
thumbClip[count].loader_mc.loadMovie(imgURL);
thumbClip[count].onEnterFrame = ThumbLoadingEnterFrame();
count++;
}
}
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success) {
if (success) {
var mySection = gallery_xml.firstChild.childNodes[0];
var picCount = mySection.childNodes.length;
for (var i = 0; i<picCount; i++) {
//Populate Arrays
count++;
thumbImage.push(mySection.childNodes*.attributes.thumbURL);
jpegImage.push(mySection.childNodes*.attributes.jpegURL);
tnHolder = _root.attachMovie("thumb_container", "tc"+count+"_mc", count);
thumbClip.push(tnHolder);
tnHolder.progress_mc._xscale = 0;
tnHolder._y = i*100;
}
count = 0;
LoadNextThumb();
} else {
trace("Error loading XML file");
}
};
gallery_xml.load("gallery.xml");