Hi All. XML is really giving me problems.
I’m working in an all flash website done in flash 8.
I’ve got a xml slide show (code below, based I think off the one on kirupa) that works.
I’ve got my main index.swf and when I press the “photo” button, I loadMovie in photo.swf into holderMC. Within photo.swf I am loading the xml for a slideshow. Everything here works. The problem arises when I press another button in index.swf and load a new .swf into holderMC where my slideshow was and then re-load photo.swf into holderMC (Most notably when done in quick succession).
When I reload photo.swf into holderMC the xml file hasn’t unloaded/reloaded and therefore the slideshow becomes “glitchy”. When I look at the Activity Moniter in my web browser it shows that the xml file hasn’t unloaded when I load another .swf into holderMC. Also, each time I load photo.swf it adds another instance of the xml file into the browser’s cache. The glitchy part affects the slideshow playback/functionality. Instead of smooth transitions with a setInterval pause the pictures loop through at varied time intervals or just flicker suggesting that the slideshow is trying to access the multiple versions of the xml file?
I guess I am confused at how to make the slideshow function properly each time photo.swf is loaded (i.e. load xml file when photo.swf is loaded and unload xml file when photo.swf is unloaded. unloadMovie does not unload the xml file.
Thanks for your help.
The following code is placed in frame 1 of photo.swf and the pictures within are loaded to “backPic” movieclip from the xml file. Also, when firstImage() is run, it loads in x amounts of the first image where x = the total number of images in the xml file. How do I fix that?
[SIZE=“1”]function loadXML(loaded) {
if (loaded) {
//xmlNode = this.firstChild;
xmlNode = this.firstChild.childNodes[0];
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();
}
// Set Item Title
titleTxt = this.firstChild.childNodes[1];
txtPath = titleTxt.childNodes[0].firstChild.nodeValue;
titleWords();
}
else {
content = “file not loaded!”;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load(“xml/photo/davis.xml”);
// Time Delay
pg = function() {
if (p<(total-1)) {
if (loaded == filesize && l1 == f1) {
nextImage();
}
}
else {
if (loaded == filesize) {
firstImage();
}
p=0;
}
}
picGo = setInterval(pg, 7000);
/////////////////////////////////////
p = 0;
g = 0;
this.onEnterFrame = function() {
filesize = backPic.getBytesTotal();
loaded = backPic.getBytesLoaded();
preloader._visible = false;
if (loaded != filesize) {
preloader.visible = false;
//preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (backPic._alpha<100) {
backPic._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
backPic._alpha = 0;
backPic.loadMovie(image[p], 1);
backPic_num();
}
}
}
function prevImage() {
if (p>0) {
p–;
backPic._alpha = 0;
backPic.loadMovie(image[p], 1);
backPic_num();
}
}
function firstImage() {
if (loaded == filesize) {
backPic._alpha = 0;
backPic.loadMovie(image[0], 1);
backPic_num();
}
}
function titleWords() {
if (loaded == filesize) {
this.itemInfo.itemTitle.text = txtPath;
}
}
function backPic_num() {
current_pos = p+1;
}[/SIZE]