Hi all
Am having problems with an XML gallery and I’m hoping someone can offer some advice.
The gallery, which is located >> here << seems to work rather inconsistently when going back and forth between different galleries. The AS I’ve used is as follows:
stop()
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
}
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("gallery1.xml");
var loadTot = 0;
var k = 0;
// ///////////////////////////////////
function preloadPic() {
clearInterval(id);
var con = picture.duplicateMovieClip("con"+k, 9984+k);
con.loadMovie(image[k]);
var temp = _root.createEmptyMovieClip("temp"+k, 99+k);
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round((loaded/total*100)/image.length);
preloader.preload_bar._xscale = loadTot+percent;
info.text = "Loading picture "+k+" of "+image.length+" total";
if (loaded == total && total>4) {
con._visible = 0;
nextPic();
loadTot += percent;
delete this.onEnterFrame;
}
};
}
function nextPic() {
if (k<image.length-1) {
k++;
preloadPic();
} else {
firstImage();
preloader._visible = 0;
info.text = "";
}
}
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
// ///////////////////////////////////
var p = 0;
var current;
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
delete this.onEnterFrame;
}
};
function nextImage() {
current = this["con"+p];
p++;
var picture = this["con"+p];
picture._visible = 1;
picture._alpha = 0;
picture.onEnterFrame = fadeIn;
picture_num();
}
function prevImage() {
current = this["con"+p];
p--;
var picture = this["con"+p];
picture._visible = 1;
picture._alpha = 0;
picture.onEnterFrame = fadeIn;
picture_num();
}
function firstImage() {
con0._visible = 1;
con0._alpha = 0;
con0.onEnterFrame = fadeIn;
picture_num();
}
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;
}
}
As well as the galleries displaying incorrectly I’m looking to get the “Loading picture x of x Total’” to display only the first time upon entering the said gallery.
If anybody could offer any help it would be much appreciated.
Cheers
Simon =)