AS3 and XML

I’m new to AS3 and its xml handling. I was referring to the tutorial (http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm) to create a dynamic slide show. Creating an xmlList and then calling upon it later to update text fields and images. Loading the xml works fine using the example provided.

But once the XMLList is created, how can I set this up so that I can access the object in other functions. I feel like I’m setting myself up for a “Duh” moment. Can anyone help?

A rough idea of what I’m trying to do…


var slideNum:Number = 1;

// Load XML //

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("xml/teasers.xml"));

function LoadXML(e:Event):void
{
    xmlData = new XML(e.target.data);
    ParseXML(xmlData);
}

function ParseXML(slideXML:XML)
{
    var slideList:XMLList = slideXML.slide;
}

function UpdateFields()
{
    var listNum:Number = slideNum - 1;
    
    title_txt.text = slideList[listNum].title.text;
    context_txt.text = slideList[listNum].title.text;
}
        
// Populate Fields //

UpdateFields();