Hi, I am a bit of a newbie when it comes to flash(but learning fast). I have an issue with the code below. This has been constructed from 2 tutorials I have found… 1 to load xml and the other to do a simple slideshow. If I seperate the xml bit and the slide show bits they work fine. If I put them together it does not work. It seems to says that the XML is undefined. It doesnt go into the loop that puts the data in the array(I have debugged that much). Any help would be appreciated… Very frustrating… I’m sure it’s something stupid I’m doing.
var picArray:Array = new Array(); //array to hold the image and all of its attributes
var thisNode:XMLNode = new XMLNode();
var imageXML:XML = new XML();
imageXML.ignoreWhite = true;
imageXML.onLoad = function(success:Boolean) {
for(var i:Number = 0;i<imageXML.firstChild.childNodes.length;i++) {
thisNode = imageXML.firstChild.childNodes*;
picArray.push([thisNode.attributes.img,thisNode.attributes.Caption,thisNode.attributes.link]);
}
//When the xml is completely loaded,
//delete the xml (since its now contained in picArray)
//and continue to the slideshow
delete imageXML;
}
imageXML.load(“pg7.xml”);
this.fadeSpeed = 20;
this.pIndex = 0;
// MovieClip methods ----------------------------------
// d=direction; should 1 or -1 but can be any number
//loads first image automatically
loadMovie(picArray[0][0],_root.photo);
MovieClip.prototype.changePhoto = function(d) {
// make sure pIndex falls within picArray.length
this.pIndex = (this.pIndex+d)%picArray.length;
if (this.pIndex<0) {
this.pIndex +=picArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.photo;
//------------------------------------------
p._alpha = 0;
p.loadMovie(picArray[this.pIndex][0]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
//trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
I have attached the fla.
Thanks
Adrian