I'm trying to take text from an XML file (this text will be translated later so it must be held externally) and import it into separate dynamic text boxes in Flash (AS2). The text boxes are organised first by row (eg r1) then by page (eg p1) and finally by text line (eg l1), so to change the text in the first row, first page, first line you'd enter r1.p1.l1.text = "sometext".
This is my XML file. The first thing I need to do is to get the id from each <txt> tag and save it as a variable that I can use as the text box identifier but I don't know how!
<?xml version="1.0" encoding="utf-8"?>
<txt id="r1.p1.l1">First line of text</txt>
<txt id="r1.p1.l2">Second line of text</txt>
The XML is called in with the following function and the text boxes should be populated accordingly - the id has to be converted to an instance name; I've tried using a variable THE_XML_ID = this[someVar] but couldn't get that to work either...
function getData()
{
var txt:XML = new XML();
txt.ignoreWhite = true;
txt.onLoad = function(success)
{
for (i = 0; i < txt.childNodes.length; i++){
THE_XML_ID.text = txt.childNodes[i].childNodes[0];
}
};
txt.load("assets/text/text.xml");
}
To sum up: I need to get the id from each <txt> tag in the XML file and use it as the text box identifier for that line of text - any help would be appreciated.