I think I’ve been staring at my code too long and I’m stuck. Can anyone help me?
I basically need to load information from an XML. Then depending on which button is clicked(apartment in a building) that specific info from the xml needs to load in a txt field.
Here is my actionscript and xml code. I’m stuck on how to assign " i " to each apartment in the building.
name = [];
sqft = [];
price = [];
avail = [];
//Load XML File
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("../xml/unit_specs.xml");
function loadXML(loaded) {
if (loaded) {
specs = this.firstChild.childNodes;
len = specs.length;
for(var i=0;i!=len;i++){
name* = specs*.childNodes[0].firstChild.nodeValue;
sqft* = specs*.childNodes[1].firstChild.nodeValue;
price* = specs*.childNodes[2].firstChild.nodeValue;
avail* = specs*.childNodes[3].firstChild.nodeValue;
}
// trace (name);
} else {
trace("file not loaded!");
}}
There are quite a few more apartments than this but here is how I have it set up.
<specs>
<unit>
<name>1A</name>
<sqft>1,033</sqft>
<price>$1,200</price>
<avail>Jan 2012</avail>
</unit>
<unit>
<name>1B</name>
<sqft>613</sqft>
<price>$900</price>
<avail>Jan 2012</avail>
</unit>
<unit>
<name>1C</name>
<sqft>419</sqft>
<price>$700</price>
<avail>Jan 2012</avail>
</unit>
<unit>
<name>1D</name>
<sqft>508</sqft>
<price>$800</price>
<avail>Jan 2012</avail>
</unit>
<unit>
<name>2B</name>
<secdep>$900</secdep>
<price>$900</price>
<avail>Jan 2012</avail>
</unit>
<unit>
<name>2N</name>
<sqft>1,033</sqft>
<price>$1,400</price>
<avail>Jan 2012</avail>
</unit>
</specs>