Hey,
I’m trying to write a variable in AS to an XML node.
I have the following nodes in my XML file:
<scores>
<firstScore>1000</firstScore>
<secondScore>900</secondScore>
<thirdScore>800</thirdScore>
</scores>
I’m displaying the XML with the following code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(“scores.xml”));
function LoadXML(e:Event):void
{
xmlData = new XML(e.target.data);
highScores(xmlData);
}
function highScores(scoreNodes:XML):void
{
boxscore_1.text = scoreNodes.firstScore.text();
boxscore_2.text = scoreNodes.secondScore.text();
boxscore_3.text = scoreNodes.thirdScore.text();
}
That works great; the xml is displayed in the text boxes. But when the user gets a new highscore I want that score to be written to the relevant XML node with the other scores moved to their new node position accordingly (I presume this part would be done using if and else statements).
I’m not quite sure how to go about this, would I need to use a PHP side server script. If so, I’d be grateful of any advise or direction to a useful tutorial.
Thanks in advance,
Ryan