我试图从xml文件加载数据,将它们加载到数组中,并在动态文本字段的不同帧中显示这些数组中的单词。例如,DynText文本字段中的两个帧将显示WordArray[0]。在此演示之后,WordArray[1]将在同一文本字段中的四个帧中显示,然后KeyWordArray[0]将在相同文本字段中显示一个帧,以此类推。
这是我到目前为止的代码:
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]);
}
}
我能够加载xml数据,将其放入数组中,并使用以下命令在动态文本字段的第一帧中显示WordArray[0]:
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.