Flex 4 中,加载XML的几种方式
发布时间:2020-12-15 04:48:06 所属栏目:百科 来源:网络整理
导读:http://www.cnblogs.com/wqing/archive/2012/02/27/2369982.html 方式一:直接加载 fx:Declarations !-- 将非可视元素(例如服务、值对象)放在此处 -- fx:XML id="myxml" source="src/xml/budui.xml"/ /fx:Declarations ? import mx.collections.ArrayColle
http://www.cnblogs.com/wqing/archive/2012/02/27/2369982.html 方式一:直接加载 <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> <fx:XML id="myxml" source="src/xml/budui.xml"/> </fx:Declarations> ? import mx.collections.ArrayCollection; import mx.collections.XMLListCollection; private var xmlList:XMLList=new XMLList(); private var xmlListCollection:XMLListCollection=new XMLListCollection(); xmlList=myxml.elements("Item"); xmlListCollection.source=xmlList; Alert.show(String(xmlListCollection[i].@Title)) 这样载入的xml是被编译进swf里的,也就是说编译以后,xml文件就没用了。 ?方式二:通过URLLoader加载 private function init():void { var loader.addEventListener(Event.COMPLETE,setResult); var req:URLRequest = new URLRequest(); req.url = "locations.xml"; loader.load(req); } private function setResult(event:Event):void { var data:XML=XML(loader.data); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |