Using a URLLoader to reference an external XML source file : URLLoader « Development « Flex






Using a URLLoader to reference an external XML source file

         
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import flash.events.Event;
        import flash.net.URLLoader;
        import flash.net.URLRequest;

        public function loadXML():void {
            var xmlLoader:URLLoader = new URLLoader();
            xmlLoader.load(new URLRequest("users.xml"));
            xmlLoader.addEventListener(Event.COMPLETE,handleLoad);
        }

        public function handleLoad(event:Event):void{
            var usersXML:XML = new XML(event.target.data);
            myTextArea.text = usersXML.toXMLString();
        }
      
    </mx:Script>
    <mx:TextArea id="myTextArea" width="250" height="100" />
    <mx:Button click="loadXML()" label="Load in XML" />
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category