One Button to addChild & removeChild
Hi all,
Can anyone show me the proper code to addChild (from lib) & removeChild using only one button.
Seem that my code not working
button_btn.addEventListener(MouseEvent.CLICK, button_mc_onPress);
function button_mc_onPress(e: MouseEvent): void
{
var popup:popup_class = new popup_class();
addChild(popup);
button_btn.removeEventListener(MouseEvent.CLICK, button_mc_onPress);
}
button_btn.addEventListener(MouseEvent.CLICK, btn_delete_onPress);
function btn_delete_onPress(e:MouseEvent) : void
{
removeChild(popup);
button_btn.removeEventListener(MouseEvent.CLICK, btn_delete_onPress);
}
& got error "1120: Access of undefined property popup."
I know it's because the "popup" is not yet exist, then i add :
var box_popup:MovieClip;
on top of the codes, the error msg is gone, when i click "button_btn" the "popup" is appear but when I click again to remove the called "popup", its still there.
Thank you.
cc: kglad
