Tree.xml文件内容如下:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:XML id="tree_popup" source="xml/tree_popup.xml"/>
</fx:Declarations>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
mx|Tree{
textAlign:left;
fontWeight:normal;
fontStyle:italic;
defaultLeafIcon:ClassReference(null);
}
</fx:Style>
<mx:ApplicationControlBar dock="true">
<mx:PopUpButton label="==请选择==">
<mx:popUp>
<mx:Tree id="treeId" width="200" dataProvider="{tree_popup}" labelField="@label" iconField="@icon"
rowCount="10" showRoot="false" defaultLeafIcon="@Embed(source='images/file.png')"/>
</mx:popUp>
</mx:PopUpButton>
</mx:ApplicationControlBar>
</s:WindowedApplication>
tree_popup.xml.xml文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<league label="American League">
<division label="West">
<team label="Los Angeles" />
<team label="Seattle" />
<team label="Oakland" />
<team label="Texas" />
</division>
<division label="Central">
<team label="Cleveland" />
<team label="Detroit" />
<team label="Minnesota" />
<team label="Chicago" />
<team label="Kanss City" />
</division>
<division label="East">
<team label="Boston" />
<team label="New York" />
<team label="Toronto" />
<team label="Baltimore" />
<team label="Tampa Bay" />
</division>
</league>
<league label="National League">
<division label="West">
<team label="Arizona" />
<team label="Colorado" />
<team label="San Diego" />
<team label="Los Angeles" />
<team label="San Francisco" />
</division>
<division label="Central">
<team label="Chicago" />
<team label="Milwaukee" />
<team label="St. Louis" />
<team label="Houston" />
<team label="Cincinnati" />
<team label="Pittsburgh" />
</division>
<division label="East">
<team label="Philadelphia" />
<team label="New York" />
<team label="Atlanta" />
<team label="Washington" />
<team label="Florida" />
</division>
</league>
</root>
其中defaultLeafIcon:ClassReference(null);可以去掉Tree中的叶子节点的图标
而defaultLeafIcon="@Embed(source='images/file.png')"可以更换Tree中叶子节点的图标