I'm trying to load an XML file with a list of books, I looked around and found this function, tried to adjust it to work for me, but I cant get this to work, I'm able to load the XML and actually read the info from it, but I was trying to set a global array or something like that so I can access the data later,
heres the code:
var books:XML = loadBooks();
trace(books); //Returns a blank output
function loadBooks():XML {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("bookList.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
trace(xmlData); //Returns what I want to have
}
return xmlData;
}
I added comments on the trace() parts to explain a little about what's happening Thanks in advance.