您的位置:首页 > 其它

递归调用---注意什么条件退出递归

2009-06-22 17:04 190 查看
public function resetToBlank(children:Array):void{

if(children.length>0){
for(var i:int=0;i<children.length;i++){
//如果是Container,才递归
if(children[i] is Container){
var container:Container=children[i] as Container;
//DisplayObjectContainer没有getChildren() 方法,Container才有
if(container.getChildren().length>0){
resetToBlank(container.getChildren());
}
}else{
var component:DisplayObject=children[i] as DisplayObject;
var componentInfo:Object = ObjectUtil.getClassInfo(component);
if(componentInfo.name == "mx.controls::ComboBox"){
component["selectedIndex"]=0;
}else if(componentInfo.name == "mx.controls::TextInput" || componentInfo.name == "mx.controls::DateField"){
if(component.hasOwnProperty("text"))component["text"]="";
}
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐