as3加载外部xml文件解析代码
//LoadXml---------------------var LoadXML:XML = new XML();var exxml:XML;//set variable exxml as xml data typevar loader:URLLoader = new URLLoader();//set variable loader as URLLLoader data typevar requestt:URLRequest=new URLRequest("as.xml");//set variable requestt as URLRequest data type with parameter(location of the external xml file)loader.load(requestt);//实例loader用方法load读取变量URLRequest实例,(读取路径)loader.addEventListener(Event.COMPLETE, image_num_fromXML_OnComplete);//实例loader注册侦听(事件为Event.COMPLETE,调用onComplete函数处理)//----------------------------------function image_num_fromXML_OnComplete(event:Event):void {//从XML文件中载入图片数量--------------------------------------------loader.removeEventListener(Event.COMPLETE, image_num_fromXML_OnComplete);exxml=new XML(loader.data);LoadXML=exxml;trace(LoadXML.children().length());//显示xml的children的数量 trace(LoadXML.photo.@thumbnail[1]);//直接读取第i个项的url值}xml的内容<?xml version="1.0" encoding="utf-8" ?> <photos> <photo thumbnail="flashmo_028_design.jpg" url="http://www.flashmo.com/preview/flashmo_028_design" /> <photo thumbnail="flashmo_029_design.jpg" url="http://www.flashmo.com/preview/flashmo_029_design" /> </photos>?