Hello All,
I am having trouble using numeric data from my xml document.
I can read the fields in to strings to trace or send to a textField,
but my goal is to use data from my xml to drive graphs.
I’d like to use the data to assign position to graphic elements, so
somehow read in as, or assigned to a variable as an Int or a Number?
So far I have not been successful referencing the P or I elements as numbers from xml
that looks like this:
<YEAR1800>
<CITY1>
<Name>New York</Name>
<Income>1,100</Income>
<I>11</I>
<Life>35</Life>
<Population>96,373</Population>
<P>10</P>
<Historic>“Historical data for this year”</Historic>
</CITY1>
<CITY2>
<Name>Philadelphia</Name>
<Income>900</Income>
<I>9</I>
<Life>36</Life>
<Population>53,722</Population>
<P>5</P>
<Historic>“Historical data for this year”</Historic>
I can read in the xml and reference other data as text strings with code that looks like so:
City1Name.text = (xmlData.YEAR1800.CITY1.Name.toString());
City1Population.text = (xmlData.YEAR1800.CITY1.Population.toString());
City1Income.text = (xmlData.YEAR1800.CITY1.Income.toString());
City1Life.text = (xmlData.YEAR1800.CITY1.Life.toString());
City1Historic.text = “Placeholder”;
So I know that works, I just don’t have a similar method to read in and use numerical data.
So far I have been trying toInt and toNumber, but I am very new to actionscript and coding and barely know what I am doing.
var P:int = xmlData.YEAR1800.CITY1.P();
var I:int = xmlData.YEAR1800.CITY1.I();
City1.x = P;
City1.y = I;
City2.x = (xmlData.YEAR1800.CITY2.I.toInt());
City2.y = (xmlData.YEAR1800.CITY2.P.toInt());
This doesn’t work but my idea is either to assign the xml address to a local variable and then drive the graphic with it or just have the graphics position reference the xml address.
Any help or advice is appreciated,
Thank You