After reading data from XML source I like to be able to show one random item from data whenever, say, clicked a button. I think I can accomplish this by storing the data into an array and use it from the array.
I would like to learn if possible to do it directly from xml without storing it into another array. Thanks in advance
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("XML_NOTES.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var loader:URLLoader = e.target as URLLoader;
var myXML:XML = new XML(loader.data);
for (i=0;i<2;i++){
trace(myXML.LEMMA[i]);
array.push(myXML.LEMMA[i]);
}
}
You can do this directly from myXML variable, you would need to set myXML as a global variable: