I have the below ActionScript that works if I remove the loadXML and use an array that I define the image names in. I'm trying to load the image names from the XML file.
I think the problem is in parsing the XML. I can trace my photoXML anywhere in the script and it will output the entire contents of my XML file, however for some reason I cannot seem to get the file name out of the XML file into the array. So, the thumbnails are not loading into the movieclip. I'm I missing something?
XML File:
Actionscript:
Dishon Gillis
Dominion Enterprises Company
I think the problem is in parsing the XML. I can trace my photoXML anywhere in the script and it will output the entire contents of my XML file, however for some reason I cannot seem to get the file name out of the XML file into the array. So, the thumbnails are not loading into the movieclip. I'm I missing something?
XML File:
Code:
<root>
<image>
<IMG_ID>1</IMG_ID>
<file>FileName0.jpg</file>
<name>Micros Boarding</name>
<brand>Micros</brand>
<description>Just a quick description of file</desc>
<img>image0.jpg</img>
<thumb>image0_thumb.jpg</thumb>
</image>
<image>
<IMG_ID>2</IMG_ID>
<file>FileName1.jpg</file>
<name>Indigo Star - Wave Surfing</name>
<brand>Indigo Star</brand>
<desc>Dude surfing on a huge wave!</desc>
<img>image1.jpg</img>
<thumb>image1_thumb.jpg</thumb>
</image>
<image>
<IMG_ID>3</IMG_ID>
<file>FileName2.jpg</file>
<name>Micros More Boarding</name>
<brand>Micros</brand>
<desc>Skateboarding in empty swimming pool.</desc>
<img>image2.jpg</img>
<thumb>image2_thumb.jpg</thumb>
</image>
</root]
Actionscript:
Code:
var photoXML:XML = new XML();
photoXML.ignoreWhite = true;
photoXML.load("MY XML LOCATION");
photoXML.onLoad = loadXML;
currentHolder = 0;
theDepth = 1000;
_global.imageLoaded = false;
_global.selectedImage = 0;
this.createEmptyMovieClip("img0_mc", theDepth++ + 10000);
this.createEmptyMovieClip("img1_mc", theDepth++ + 10000);
function loadXML (loaded) {
if (loaded) {
var xmlParse:XmlNode = photoXML.firstChild;
var thumb_arr:Array = new Array();
total = xmlParse.childNodes.length;
for (i = 0; i < total; i++) {
thumb_arr[i] = xmlParse.childNodes[i].childNodes[6].firstChild.nodeValue;
this.createEmptyMovieClip("thumb" + i + "_mc", theDepth++);
this.createEmptyMovieClip("thumb" + i + "_tmp_mc", theDepth++);
this["thumb" + i + "_mc"]._x = 6;
this["thumb" + i + "_mc"]._y = 10 + 108 * i;
this["thumb" + i + "_mc"].loadMovie("IMAGE FOLDER LOCATION" + thumb_arr[i]);
this["thumb" + i + "_tmp_mc"].no = i;
this["thumb" + i + "_tmp_mc"].onEnterFrame = function() {
var l = this._parent["thumb" + this.no + "_mc"].getBytesLoaded();
var t = this._parent["thumb" + this.no + "_mc"].getBytesTotal();
if ((l >= t) && (t > 1) && (this._parent["thumb" + this.no + "_mc"]._width > 1)) {
this._parent["thumb" + this.no + "_mc"].num = this.no;
this._parent["thumb" + this.no + "_mc"].onPress = function() {
if ((_global.selectedImage != this.num) && (_global.imageLoaded)) {
loadImage(this.num);
}
};
delete this.onEnterFrame;
this.removeMovieClip();
}
};
};
}
};
Dishon Gillis
Dominion Enterprises Company