开发者

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

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜