how to remove/unload a button in actionscript 3 - flash?
i have a button and i am trying to 开发者_StackOverflowunload it but i dont know how.
I add the child as follows : addChild(buttons);
I try to remove it by : removeChild(buttons);
but this does not work, nothing happens. Any ideas?
you are probably losing an instance of that button from your code, most likely because the button was temporarily defined in a function.
2 options create a global instance of the button.
or the add the instance of that button into a list
var list:Array = new Array(); //define a global array
var b1:Button = new Button () //I honestly don't remember the synthax for creating a button
list.push(b1);
then when ever you want to remove the buttons from stage just do the following:
for(int i=0; i<list.length;i++){
removeChild(list[i]);
}
Odd that that doesn't work but if it is just one button you can do it like this.
buttons.parent.removeChild(buttons);
精彩评论