Hey,
I am using a modified versions of the Kirupa slideshow that preloads all the photos from the XML file. Also modified the first frame to be a logo and a phrase instead of a photo. I’m having problems trying to get the movie back to the first frame after it finishes the slideshow. Either gets stuck in an endless loop, or the the final picture won’t go away. Any help would be much appreciated. Code is below.
delay = 4000;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
phrase = [];
logo = [];
image = [];
description = [];
total = xmlNode.childNodes[2].childNodes.length;
for (i=0; i<total; i++) {
phrase = xmlNode.childNodes[0].firstChild.nodeValue;
logo = xmlNode.childNodes[1].attributes.PATH;
image* = xmlNode.childNodes[2].childNodes*.attributes.PATH;
description* = xmlNode.childNodes[2].childNodes*.firstChild.nodeValue;
}
id = setInterval(preloadPic, 100);
//firstImage();
} else {
content = "file not loaded!";
}
}
//pass _root variable in movie call
//so.addVariable("guiPropertyCombinedID", "d7dd587f-8c97-4c54-bf3a-e2fb2e08d741");
XMLfile = "../developmentXML/"+_root.guiPropertyCombinedID+".xml";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(XMLfile);
var loadTot = 0;
var k = 0;
//p = 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();
trace("hit");
}
}
/////////////////////////////////////////
var p = 0;
var current;
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 3;
this._alpha += 3;
} 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;
desc_txt.text = description[p];
picture_num();
slideshow();
}
function prevImage() {
current = this["con"+p];
p--;
var picture = this["con"+p];
picture._visible = 1;
picture._alpha = 0;
picture.onEnterFrame = fadeIn;
desc_txt.text = description[p];
picture_num();
}
function firstImage() {
picture.unloadMovie();
phrase_txt.text = phrase;
logoHolder._alpha = 100;
logoHolder.loadMovie(logo, 1);
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
phrase_txt.text = "";
logoHolder._alpha = 0;
con0._visible = 1;
con0._alpha = 0;
con0.onEnterFrame = fadeIn;
desc_txt.text = description[0];
picture_num();
slideshow();
}
}
function picture_num() {
maskerLeft.swapDepths(10000);
maskerRight.swapDepths(10001);
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
gotoAndPlay(1);
} else {
nextImage();
}
}
}
Thanks,
Brett