<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" fontFamily="simsun" fontSize="12" layout="absolute" width="242" height="442" creationComplete="initApp()"><mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; public var loader:URLLoader=new URLLoader(); public var menus:XML=new XML(); [Bindable] public function completeHandle(e:Event):void { menus=XML(loader.data); var results:XMLList=menus.node; tree.dataProvider=results; } public function initApp():void { var request:URLRequest=new URLRequest("TreeMenus.xml"); loader.load(request); loader.addEventListener(Event.COMPLETE,completeHandle); } ]]></mx:Script> <mx:Tree id="tree" x="10" y="35" width="218" height="397" labelField="@label" /> <mx:Label x="10" y="10" text="Tree Nodes From XML File"/></mx:Application> /////////////////////////////总结1.用到URLLoader和URLRequest,加载完成时触发COMPLETE事件,在处理函数中绑定到Tree上 相关文章: