reading a url with flash
I have a flash applet that I want 开发者_开发问答to grab a remote XML file and read it in as a string, how can I do this?
You can use a URLLoader to do this.
var url:String = 'http://www.myurl.com/myxml.xml';
var req:URLRequest = new URLRequest( url );
var urlloader:URLLoader = new URLLoader();
urlloader.addEventListener( Event.COMPLETE, XMLLoaded );
urlloader.load( req );
function XMLLoaded( e:Event ):void {
trace( urlloader.data ); //urlloader.data is a String
var xml:XML = XML( urlloader.data ); //create an AS3 XML object from the xml string
}
精彩评论