URLLoader() -- event listener nightmare

Sooo, I’m about to pull my hair out, and I hope that someone can help me.

I’m just trying to create a relatively simple application for my research, and I’m using URLLoader() to retrieve quite a lot of XML data.

Project Overview (that’s relevant)
The XML data is a bunch of numbers that I need to display on a graph as soon as the page is loaded. So, it must be parsed and the values remapped to the height of the panel for display purposes.

The mostly relevant code
(Side note about openXML(): This function either needs to return some data, or in my controller, I need to be able to make a call to a getData() function. But that’s not possible because there’s no guarantee that the XML data has been loaded yet.)


/* openXML() is being called by my controller, which is called by my application's initialize.*/

public function openXML():void {        
            var loader:URLLoader = new URLLoader();
            loader.addEventListener(Event.COMPLETE, loadXML);
            loader.load(new URLRequest(xmlURL));
        }
 
 private function loadXML(evt:Event):void {
            var xml:XML = new XML(evt.target.data);
            
            // setup all <R> (Reading) tags as an xml list
            xmlList = xml.R;
            
            for (var i:int=0;i<xmlList.length();i++) {
                value*=xmlList.v*;
            }    
            
            // each value will then need to be remapped to fit the panel
            // call the gsrController -- which will in turn draw all this stuff        
    }


So the problem is, I’m new to Flex. I would LOVE for a way for the openXML() file to be able to return the xmlList so that I can take all of that logic OUT of that event listener (If the logic stays in there, it will time out). But how could I accomplish that? It’s not like I can tell openXML() to wait on that event listener before it returns anything – haha.

When I was testing this stuff a few days ago, everything was working perfectly fine, but it was when I used data that corresponded to 40 minutes worth of video that it became a problem.

(And to provide a better overview of what I’m doing, the XML data is for drawing this line that the video player ticker is syncing up with as the video players…)

Anyway, I would really appreciate some advice from more seasoned ActionScript programmers. :bu: