Hi,
I am new to actionscript and am currently using the following script to load 25 images into a movieclip container (“lgpicture”) from an external .xml file. The problem is that each image loads individually and there is a long pause between viewing each image for the first time. Instead I would like, if possible, to use a preloader that will load all images at once, before any image is viewed with a percentage bar or something like that. I am unfortunately unable to compromise on the image size (some well over 500K) but one long pause in the beginning is much more favorable than pausing between each image. I would really appreciate any help I can get!!!
code:
lgpicture._x=0;
lgpicture._y=30;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“images1lg.xml”);
/////////////////////////////////////
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = lgpicture.getBytesTotal();
loaded = lgpicture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (lgpicture._alpha<100) {
lgpicture._alpha += 10;
}
}
};
function firstImage() {
if (loaded == filesize) {
lgpicture._alpha = 0;
lgpicture.loadMovie(image[0], 1);
desc_txt.text = description[0];
lgpicture_num();
}
}
function lgpicture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}