Skip to main content
Participant
November 27, 2022
Question

Actionscript: Argument Error

  • November 27, 2022
  • 1 reply
  • 161 views

How do I deal with an error when pressing the button repeatedly for bring up a pop up which causes the pop up not be removed like this?

 

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/removeChild() at sempoakuadran_Mainmenu_fla::MainTimeline/removePopupExit()[sempoakuadran_Mainmenu_fla.MainTimeline::frame67:106] at sempoakuadran_Mainmenu_fla::MainTimeline/closePopupExit()[sempoakuadran_Mainmenu_fla.MainTimeline::frame67:111]

 

 

 

The code created by me is like this:

 

var popupExit = new ExitPopUp;
var isPopup = false;

function addPopupExit(str=""):void{
popupExit = new ExitPopUp;
popupExit.popupTxt.text = str;
popupExit.yaBtn.addEventListener(MouseEvent.CLICK, keluarApk);
popupExit.tidakBtn.addEventListener(MouseEvent.CLICK, closePopupExit);
popupExit.x = 1000;
popupExit.y = 540;
addChild(popupExit);
isPopup = true;
}

function removePopupExit():void{
popupExit.yaBtn.removeEventListener(MouseEvent.CLICK, keluarApk);
popupExit.tidakBtn.removeEventListener(MouseEvent.CLICK, closePopupExit);
removeChild(popupExit);
isPopup = false;
}

function closePopupExit(e:MouseEvent):void{
removePopupExit();
}

exitBtn.addEventListener(MouseEvent.CLICK, tampilkanPopupExit);

function tampilkanPopupExit(e:MouseEvent):void{
addPopupExit("Apakah Anda ingin keluar dari aplikasi ini?");
}

function keluarApk (e:MouseEvent):void{
NativeApplication.nativeApplication.exit(0);
}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 27, 2022

if(popupExit.parent){
popupExit.parent.removeChild(popupExit)

}