实际
我想从VBox中移除Child,我有孩子的id,但我不想使用VBox的removeChild函数删除我想删除的真实对象
答案 0 :(得分:3)
var elem:Type_of_E = this["constructed_id_of_E"];
答案 1 :(得分:1)
假设您在运行时之前知道VBOX的名称:
yourVBOX.removeChild( yourVBOX.getChildByName('yourChildID') );
答案 2 :(得分:1)
如果您要移除子项的ID,则您拥有真实对象。 id
中的mxml
属性通过它的值创建一个公共变量,并在该变量中存储对该对象的引用。
if(childId != null)
vbox.removeChild(childId);
else
trace("Normally this shouldn't happen in flex");
//or if you don't have VBox's id but you are sure that
//the child is in fact is parented by a container:
childId.parent.removeChild(childId);
答案 3 :(得分:0)
您可能还想在组件上设置“name”属性,例如:
myLabel.name = "LabelX";
myLabel.id = "LabelX"; // eventually
然后继续做第一个回答说,
yourVBOX.removeChild( yourVBOX.getChildByName('LabelX') );
要记住的是设置名称和ID,没有“getChildByID”这样的方法: - )
答案 4 :(得分:-1)
getChildByID:
this.getChildren()[id]