/ Published in: ActionScript 3
As3 load from XML----------------------
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//�root.xmlä¸Â读�status,a����������询xml public static function readStatus(a:String):ArrayCollection{ var xml:XML; var xmlList:XMLList; var xmlLoader:URLLoader = new URLLoader(); var arr:ArrayCollection = new ArrayCollection(); xmlLoader.load(new URLRequest("pb/utils/root.xml")); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); function xmlLoaded(event:Event):void { xml = XML(event.target.data); //��scope�� xmlList = xml..userStatus.(@scope==a); //trace(xmlList[0].@label); for(var i:int = 0; i < xmlList.length(); i++) { //�xmlList转�为object类� var o:Object = new Object(); o.label = xmlList[i].@label; o.data = xmlList[i].@data; arr.addItemAt(o,i); } } return arr; }