Hello,
I’m trying to make an order form that would be closed from a button. I know this is simple question, but how the odd thing is that when I press the close button named btn the first time everything works fine. The second time I open the form and close it I get an error message:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild() at MethodInfo-994()
The third time I open and close the form I get the error two times. The fourth time I open and close the form I get the error four time etc… I think you get the idea… The problem must be somewhere in removing the child and then adding it again and removing. Can someone help me please? Here is the code:
var container:Sprite = new Sprite();
addChild(container);
var forma1:Loader = new Loader();
var urlReq:URLRequest = new URLRequest(“file.swf”);
forma1.load(urlReq);
forma1.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
function loaded(event:Event):void
{
container.addChild(forma1);
btn.addEventListener(MouseEvent.CLICK, closeforma);
function closeforma(event:MouseEvent):void
{
container.removeChild(forma1); // I also tried removeChild(container) without any better luck…
}
}