//1:flex tree 默认选择树节点 var modouleName:String;//节点主键 private function GetSelectedItem():void { for(var i:int = 0;i<treList.dataProvider.length;i++) { var xml:XML = (treList.dataProvider as XMLListCollection).getItemAt(i) as XML var xmlIst:XMLList= xml.children(); if(treList.dataProvider[i].@Node == modouleName) { treList.selectedIndex = i; break; } if(xmlIst.length()>0) { validateNow(); treList.expandChildrenOf(xml,true); getSe(xmlIst); if(isSelect) break; } } } private function getSe(xml:XMLList):void { for(var i :int=0;i<xml.length();i++) { if(xml[i].@Node==modouleName) { treList.selectedItem=xml[i]; isSelect=true; break; } else { isSelect=false; } } }