本文章用到checkboxTree的渲染器,请到我的博客查看:
http://blog.csdn.net/xuhuanchao/archive/2009/11/25/4873725.aspx
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Tree labelFunction="treeFun" x="10" y="10" width="199" height="327" id="tree" folderOpenIcon="@Embed
(source='img/add_folder.png')"
defaultLeafIcon="@Embed(source='images/scroll_arrow_down_over.png')" creationComplete="load()"
fontSize="14" itemClick="choose(event)"
openEasingFunction="Bounce.easeOut" openDuration="500" itemRenderer="com.checkboxRenderer">
</mx:Tree>
<mx:XML id="treeXMLSource">
<node label="grandFather">
<node label="father">
<node label="me">
<node label="son">
<node label="grandson">
<node label="greatGrandSon"/>
</node>
<node label="granddaughter"/>
</node>
<node label="daughter"/>
</node>
</node>
<node label="Uncle"/>
<node label="Aunt">
<node label="cousin"/>
<node label="cousin"/>
</node>
</node>
</mx:XML>
<mx:Script>
<![CDATA[
//tree项目点击事件,判断选中的值
private function choose(event:ListEvent):void
{
CursorManager.setBusyCursor();
var xmll:XMLList=treeXMLSource.children();
findChecked(xmll);
CursorManager.removeBusyCursor();
}
//递归查询
private function findChecked(xmllist:XMLList):void{
for(var i:int=0;i<xmllist.length();i++)
{
if(xmllist[i].@state=="checked")
{
Alert.show(xmllist[i].@label);
//break;
}
if(xmllist[i].hasComplexContent()){//检查是否是复杂数据
findChecked(xmllist[i].children());
}
}
}
]]>
</mx:Script>
</mx:Application>