Is it possible to save/store variables to be used out of event handlers?

Hello all, I’m wondering if it is possible to create, save, or store variables in event handlers (or functions invoked in them), to be used outside in the main body of a program. I am working on a project that is requiring me to load an XML file and then manipulate certain children in the file. Basically I’m trying to make a question and answer post with the XML storing the actual question and answers, also I’m trying to read in the max number of questions the XML file holds, and any other information. My problem is is that data stored in variables during the event or the function invoked due to the event isn’t saved afterward.

Here’s a simple code from a site on google dealing with loading XML below for reference:

var loadmyXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest(“test.xml”));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {
loadmyXML = new XML(e.target.data);
trace(myXML);
}

After the event is processed loadmyXML is emptied, so using it in the main body is pointless since the object doesn’t contain any data. In C/C++ you’d have to pass objects by reference in order to modify them for outside use, but I haven’t seen ANY syntax to show how you’d do that in events here. Like I’d prefer to save loadmyXML, store loadmyXML.questions.length() in a variable also, etc.

It’s been a long time since I’ve used global variables in C so I’ve forgotten how they really work, but couldn’t you just address them / change them inside of a function without ever calling them and it would reflect outside in the main program? Will something similar have to be done (if it’s even possible) in AS3? I’ve been looking for some clarity on the problem and haven’t had much luck. Any help would be appreciated, and if way this isn’t possible is there another method to go about extracting the XML in order to actually save it? I mean it has to be possible, people have coded games like trivial pursuit to run in flash and so forth, but I haven’t had much luck finding anything :(. Thanks again in advance for any help!