Loading XML Data from External Sources : URLRequest « Network « Flash / Flex / ActionScript






Loading XML Data from External Sources

 

package{
  import flash.display.Sprite;
  import flash.net.*;
  import flash.events.*;

  public class Main extends Sprite{
        var myXML:XML;
        var url:URLRequest = new URLRequest("http://www.your-domain.com/test.xml");
        var loader:URLLoader = new URLLoader(url);
    public function Main(){
        loader.addEventListener(Event.COMPLETE, onLoadComplete);
    }
    function onLoadComplete(event:Event):void {
       if (loader.data) {
          myXML = XML(loader.data);
       }
    }
  }
}

        








Related examples in the same category

1.Add URLrequest to Loader
2.Loading XML Data: Event.COMPLETE listener
3.Loading a bitmap at runtime
4.Formatting text with an externally loaded style sheet
5.Starting the load operation
6.Adding an asset to the display list
7.Use FileReference to download file from a URL