Q:

How can I access XML nodes of an xml list AS3?

The class example:
package {

    import flash.events.*;
    import flash.net.*;

    public class XmlLoader extends EventDispatcher{

        private var _xmlList:XMLList;

        public function XmlLoader(xmlPath:String){
            var xmlUrlRequest:URLRequest = new URLRequest(xmlPath);
            var xmlUrlLoader:URLLoader =  new URLLoader(xmlUrlRequest);
            xmlUrlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
        }

        private function xmlLoaded(e:Event):void{
            e.currentTarget.removeEventListener(Event.COMPLETE, xmlLoaded);
            var xml:XML = new XML(e.currentTarget.data);
            this._xmlList = xml.*;
            dispatchEvent(new Event(Event.COMPLETE));
        }

        public function getXmlList():XMLList{
            return this._xmlList;
        }

    }
}

An example of the class use would be:
var menuXmlList:XmlLoader = new XmlLoader("pt/menu.xml");
menuXmlList.addEventListener(Event.COMPLETE, printList);

function printList(e:Event):void{
    trace(e.currentTarget.getXmlList());
}

This will print out the content of the xml file.
How can I access the nodes of the xmlList outside the class?

A:

I would modify a little the loader
     public class XmlLoader extends EventDispatcher{
        private var _xml:XML;

        public function XmlLoader(xmlPath:String){
            var xmlUrlRequest:URLRequest = new URLRequest(xmlPath);
            var xmlUrlLoader:URLLoader =  new URLLoader(xmlUrlRequest);
            xmlUrlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
        }

        private function xmlLoaded(e:Event):void{
            e.currentTarget.removeEventListener(Event.COMPLETE, xmlLoaded);
            _xml = new XML(e.currentTarget.data);
            dispatchEvent(new Event(Event.COMPLETE));
        }

        public function getXml():XML{
            return this._xml;
        }

    }
}

I will then access the nodes like this.
var menuXmlList:XmlLoader = new XmlLoader("pt/menu.xml");
menuXmlList.addEventListener(Event.COMPLETE, printList);

function printList(e:Event):void{
    var myXML:XML = (e.currentTarget.getXml());

    var children:XMLList = myXML.children();
    var child:XML;

    for each(child in children)
    {
         trace("Node name: "+child.name()+" -- value: "+String(node));
    }

    // for and xml like
    // <root>
    //     <node1>
    //           <subnode>abc</subnode>
    //           <subnode>def</subnode>
    //           <subnode>ghi</subnode>
    //     </node1>
    //     <node2>
    //           <subnode>123</subnode>
    //           <subnode>456</subnode>
    //           <subnode>789</subnode>
    //     </node2>
    // </root>
    //
    // to access all subnodes inside node 2 use
    //
    // var list:XMLList = xml.node2.subnode;

}

