flex实现树的代码,希望对大家有所帮助 Tree.mxml的代码如下: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" height="642"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <s:Panel x="114" y="72" width="189" height="324"> <mx:Tree labelField="@label" showRoot="false" x="10" y="10" height="271" > <mx:dataProvider> <fx:XML xmlns="" source="dir.xml" > </fx:XML> </mx:dataProvider> </mx:Tree> </s:Panel> </s:Application> 所需要的数据的代码如下: <?xml version="1.0" encoding="GB2312"?> <nodes> <node1 label="界别"> <node2 label="七年级"/> </node1> <node1 label="考试类型"> <node2 label="期中考试"/> <node2 label="期末考试"/> </node1> <node1 label="年级"> <node2 label="六年级"/> </node1> </nodes>