Howdy. I’ve done some Googling on this but to no avail. I’m trying to load an external text file and a jpg image from an xml file. I’ve got the list box working and the text loading however I can’t seem to access the “pic” attribute in the xml file. (I get the “undefined” error for the jpg in output). I’ve kind of hacked this code together so it’s probably not the prettiest but It seems close to me. It seems that “data” just references the second attribute in line no matter what it it. I can switch around the “pic” and the bio info attributes in the AS and the jpgs load but not the text. I’ve tried all sorts of crazy things but the last is below. any help would be greatly appreciated.
thanks, Shag
here’s the AS:
// bios text field ------------
var bio_lv:LoadVars = new LoadVars();
bio_lv.onData = function(srcBio:String) {
if (srcBio != undefined) {
bios_txt.htmlText = srcBio;
} else {
trace("Could not load text file.");
}
};
// STOP bios text field ------------
var xmlbio:XML = new XML();
xmlbio.ignoreWhite = true;
xmlbio.onLoad = function() {
var nodesbio = this.firstChild.childNodes;
for(i=0;i<nodesbio.length;i++) {
listbio.addItem(nodesbio*.attributes.desc,nodesbio*.attributes.bioinfo,nodesbio*.attributes.pic);
}
listbio.selectedIndex = none;
}
xmlbio.load("bios/bios.xml");
var lListbio:Object = new Object();
lListbio.change = function() {
bio_lv.load(listbio.getItemAt(listbio.selectedIndex).data);
loadMovie(listbio.getItemAt(listbio.selectedIndex).data.pic, "bioPicHolder"); //this is the line I'm having trouble with...
}
listbio.addEventListener("change", lListbio);
and here’s the xml
<?xml version="1.0" encoding="utf-8" ?>
<biolist>
<bio desc="Mark Pruett - Senior Editor" bioinfo="bios/bio1.txt" pic="bios/bio1.jpg" />
<bio desc="Tim Moore - Senior Editor" bioinfo="bios/bio2.txt" pic="bios/bio2.jpg" />
<bio desc="Jane Doe - Senior Editor" bioinfo="bios/bio3.txt" pic="bios/bio3.jpg" />
<bio desc="Bob Daviston - Senior Editor" bioinfo="bios/bio4.txt" pic="bios/bio4.jpg" />
<bio desc="John Doe - Senior Editor" bioinfo="bios/bio5.txt" pic="bios/bio5.jpg" />
</biolist>