tags:

views:

501

answers:

4

Acctually

I want to remove Child from VBox , i have id of child , but i don't to have real object that i want to remove using removeChild function of VBox

+1  A: 

Assuming you know the name of your VBOX before runtime:

yourVBOX.removeChild( yourVBOX.getChildByName('yourChildID') );

Read more on: LiveDocs - Container - getChildByName

Robert Bak
+1  A: 

If you have the id of the child to be removed, you have the real object. id attribute in mxml creates a public variable by it's value and store a reference to the object in that variable.

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);
Amarghosh
A: 

You might also want to set the "name" property on your component, such as :

myLabel.name = "LabelX";
myLabel.id = "LabelX"; // eventually

Then proceed to doing as the first answer said,

yourVBOX.removeChild( yourVBOX.getChildByName('LabelX') );

The thing to remember is to set the name as well as the ID, there is no such method as "getChildByID" :-)

Dr1Ku
A: 

getChildByID:

this.getChildren()[id]

Techie