//根据关键字查找节点 private var temp:int = 0; private function searchCategory(key:String):void { var list:XMLList = goodsModel.categorys.descendants().(@name.indexOf(key) != -1); if(key.length == 0) { closeAllCategory(); } else { if(list.length() == 0) { Alert.show("没有找到相关信息!请重试","提示"); } else if(list.length() == 1) { //展开并选中 expandParents(list[0]); myTree.selectedItem = list[0]; //显示信息 根据查询的节点显示节点的详细信息 方法没写 findCategoryById(XML(list[0]).@id); } else if(list.length() > 1) { if(temp < list.length()) { expandParents(list[temp]); myTree.selectedItem = list[temp]; } else { temp = 0; expandParents(list[temp]); myTree.selectedItem = list[temp]; } findCategoryById(XML(list[temp]).@id); temp ++; } } }