The script below creates a slideshow of images. I’ve been trying to create (1) a preloader that will load all the images before showing any of them or (2) a preloader for each individual image.
Can anyone help?
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("food.xml");
////////////// arranges contents of XML data into two arrays
///// image - which is a url to the image
///// widths - the width of the image (necessary for setlocation() function)
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
widths = [];
totalwidths = [];
totalwidths[0] = 0;
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
widths* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
for (i=0, count=0, j=1; i<total; i++, j++) {
y = widths* - 0;
count = count+ y + 3;
totalwidths[j] = count;
}
loadimages();
}
};
/////////// loads the images into individual movieclips
function loadimages() {
widths = [];
var totalwidth = 0;
for (i=0;i<total; i++) {
var picref = this.createEmptyMovieClip("container"+i,i);
picref.loadMovie(image*);
}
setLocation();
};
//////////////// sets the _x location of the images
function setLocation() {
for (i=0; i<total; i++) {
var contain = "container"+i;
setProperty (contain,_x,totalwidths*);
}
};
////////////////// scoller limits
this.onEnterFrame = function() {
var rightposition = (700 - 344 - totalwidths[total]);
if (_root.nav.contents._x >= -344) {
tellTarget ("_level0.nav.scroller.scroll_right") {
gotoAndStop(1);
enabled = false;
}
} else {
tellTarget ("_level0.nav.scroller.scroll_right") {
enabled = true;
}
}
if (_root.nav.contents._x <= rightposition) {
tellTarget ("_level0.nav.scroller.scroll_left") {
gotoAndStop(1);
enabled = false;
}
} else {
tellTarget ("_level0.nav.scroller.scroll_left") {
enabled = true;
}
}
};