mardi 28 mars 2017

Changing dynamic text with external xml file

I have a very specific task and I can't seem to make it work. I have an Animate file with a graphic symbol (named help) which contains a dynamic text area (named help_txt) with some text in it. I want to change it with external xml file. My Xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<frame>
    <first>Begin your adventure here.</first>
    <second>We continue here</second>
</frame>    

I uploaded an external XML file in the following way:

var myXml:XML = new XML();  
myXml.ignoreWhite = true;  
var myLoader:URLLoader = new URLLoader();  
myLoader.load(new URLRequest("test_eng.xml"));  
myLoader.addEventListener(Event.COMPLETE, processXML)  
function processXML(e:Event):void {  
    myXml = new XML(e.target.data);  
    parsFramText();  
}  
function parsFramText(){  
    help_txt.text = myXml.first.text;  
}    

Aucun commentaire:

Enregistrer un commentaire