I’ve just recently started learning actionscript with most of knowledge coming from this site and others like it.
My website loads external swfs by clicking a button. In these swfs is dynamic text and a slideshow. It load the text and images from an xml file. As you click around the website the slideshow stops working properly. I’m not really sure why this happening. Does anyone have any suggestions?
Here is the code for the slideshow.
delay = 3000;
frame.swapDepths(9999); //image on top of slideshow
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.firstChild.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.firstChild.childNodes*.childNodes;
}
text_holder.text = xmlNode.firstChild.nextSibling.childNodes;
id = setInterval(preloadPic, 100);
} else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(‘xmlcode/symbols.xml’);
var p = 0;
var current;
var k = 0;
function preloadPic() {
clearInterval(id);
var con = picture.duplicateMovieClip(“con”+k, 9+k);
con.loadMovie(image[p]);
preloader._visible = 0;
preloader.swapDepths(con.getDepth()+3);
con._alpha = 0;
var temp = _root.createEmptyMovieClip(“temp”+k, 2+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
delete this.onEnterFrame;
}
};
slideshow();
}
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};
function nextImage() {
p<total-1 ? (p++, preloadPic()) : null;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = -1;
nextImage();
} else {
nextImage();
}
}
}
stop();