Monday, May 14, 2012

[Action Script] Pulling Specific Data from XML May,2012

I need to be able to use as2 to search through my XML file and populate dynamic text field with certain data. Here's and example of my xml:

//-------------------- AS2 --------------------
function loadXML(loaded) {

if (loaded && typerank == "1"){

_root.firstperiod = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.typerank= this.firstChild.childNodes[0].childNodes[6].firstChild.nodeValue;

ffscore1_1_txt.text=_root.typingtest;
ffname1_1_txt.text = _root.firstperiod;
}else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("firstperiod.xml");
//-------------------- End AS2 --------------------

When I use this my xml doesn't load.

My xml actually looks like this:

//-------------------- XML --------------------
<fp>
<name>Last, First</name>
<abyss>736</abyss>
<abyssrank>6</abyssrank>
<adventure>35498</adventure>
<adventurerank>12</adventurerank>
<typingtest>19</typingtest>
<typerank>12</typerank>
<abysslw>736</abysslw>
<adventurelw>35498</adventurelw>
<typingtestlw>19</typingtestlw>
</fp>
//-------------------- End XML --------------------

I'm already using this xml to extrapolate data out of in other areas of the site and it works great. Now I just want to use it more in a different location to look at the "*rank" labels and see if they == 1, 2 or 3 and then fill in dynamic fields with the name, and score data. So I want to search for the highest grade and fill in a dynamic text field, or maybe the second highest grade and pull that data, and the name of the person. How could I do this?

Thanks!
Pulling Specific Data from XML

Related Post



0 comments: