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"]="";
}
}
}
}
}
本文介绍了一个用于Flash AS3应用程序中UI组件重置到空白状态的方法。该方法能够递归地处理容器内的子元素,并针对特定类型的UI组件如ComboBox和TextInput执行特定的重置操作。
855

被折叠的 条评论
为什么被折叠?



