I have problem with removeChild in XML button menu
im calling button temp from library with Linkage
here is my code where i write it
var genButton:butonProba;
var i:uint = 0;
for each (var page:XML in generacijeXML.gener.generation) {
genButton = new butonTest();
genButton.butonText.text = page.@name;
genButton.source = page.source.toString();
genButton.butonText.autoSize = TextFieldAutoSize.LEFT;
genButton.x = 16 + i*225;
genButton.y = -30;
genButton.buttonMode = true;
genButton.mouseChildren = false;
addChild(genButton);
i++;
}
and everything is normal…..
now when i want to make 1 more button when i click on it i want to remove all xml buttons which i call before
im trying simple like this
close.addEventListener(MouseEvent.CLICK, closed);
function closed(event:Event):void {
genButton.removeChild(0);
}
and this
close.addEventListener(MouseEvent.CLICK, closed);
function closed(event:Event):void {
removeChild(genButton);
}
but dont work
does any1 have idea how can i do that ???
I would add all buttons in one container. Create the container as an instance member and add it to the stage in the constructor or your init method:
In your loop add all the created buttons to this container:
in you click handler remove all children from the container:
hope that helped