Hi I have a xml photogallery that I’m loading into an empty movie clip in my main movie. I can preload each image seperatly but would like to have a preloader that preloads either all or a certain percentage of the images and then starts the gallery. Does anyone have any suggestions. Thanks. I’ve provided the code below. I’m using mx 2004. Here’s a link
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
//declare image and description as array
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.text = "file not loaded!";
}
}
xmlAlbum = new XML();
xmlAlbum.ignoreWhite = true;
xmlAlbum.onLoad = loadXML;
xmlAlbum.load("color.xml");
//////////////////////////////////////////////
p = 0;
function nextImage() {
if (p<(total-1)) {
p++;
color_mc.loadPhoto(image[p]);
desc_txt.text = description[p];
picture_num();
}
}
function prevImage() {
if (p>0) {
p--;
color_mc.loadPhoto(image[p]);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
color_mc.loadPhoto(image[0]);
desc_txt.text = description[p];
picture_num();
}
///////////////////////////////////////////////
var SPACING = 10
color_mc._alpha = 0;
MovieClip.prototype.loadPhoto = function(photo) {
color_mc._alpha = 0;
this.loadMovie(photo);
_level0.onEnterFrame = function() {
// modified the total and loaded so as to round it up
// to smaller number.
var total = color_mc.getBytesTotal();
var loaded =color_mc.getBytesLoaded();
if (total != 0 && Math.round(total/loaded) == 1 && color_mc._width>0)
{
var w = color_mc._width+SPACING, h = color_mc._height+SPACING;
color_border.resize(w, h, pic);
delete this.onEnterFrame;
}
};
};
MovieClip.prototype.resize = function(w, h, pic)
{
//the higher the slower the resize of the border
var speed = 2;
color_mc._alpha = 0;
this.onEnterFrame = function()
{
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
if (Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1)
{
this._width = w;
this._height = h;
color_mc._x = this._x-this._width/2+SPACING/2;
color_mc._y = this._y-this._height/2+SPACING/2;
color_mc._alpha += 20;
if (color_mc._alpha>90)
{
color_mc._alpha = 100;
delete this.onEnterFrame;
}
}
};
};
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
if (p == 0) {
previous_btn._alpha = 50;
previous_btn.enabled = false;
} else {
previous_btn._alpha = 100;
previous_btn.enabled = true;
}
if (p == (total-1)) {
next_btn._alpha = 50;
next_btn.enabled = false;
} else {
next_btn._alpha = 100;
next_btn.enabled = true;
}
}