I'm trying to load data from an xml file, load them in arrays and present words from these arrays in different frames in a dynamic text field. So for example, WordArray[0] will be presented for two frames in the DynText textfield. Following this presentation, WordArray[1] will be presented for four frames in the same text field and then KeyWordArray[0] will be presented for one frame in the same text field, etc.
Here is the code I have so far:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("file2.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParsePass(xmlData);
}
var WordArray:Array = new Array();
var KeyWordArray:Array = new Array();
function ParsePass(passInput:XML):void {
var WordAll:XMLList = passInput.Pass.Word.text();
var PrimeAll:XMLList = passInput.Pass.Keyword.text();
for (var i in WordAll) {
WordArray.push(WordAll[i]);
}
for (var p in PrimeAll) {
KeyWordArray.push(PrimeAll[p]);
}
}
I am able to load the xml data, put it in arrays and present WordArray[0] in the first frame in a dynamic text field using:
DynText.text = WordArray[0];
but not in the other frames. I have tried to call functions within the ParsePass function, but it does not seem to work. I am sorry if this is a basic question. I am new to AS3. But I have searched the web and did not find any relevant answer to my question. So any help would be very appreciated.
Read about parsing XML here: XML Basics
For adding various data on frames try using addFrameScript();
You can add code to specific frame to load data to a container which is located on that frame. Or another solution would be to use the same container on all the frames but load data dynamically depending on the frame number.
EDIT:
Also note that in Flash frame enumeration starts from 1 and make sure you stop the MovieClip on the frame you need, using the stop() method.