# removeChild error

**URL:** <https://forum.kirupa.com/t/removechild-error/268864>\
**Category:** flash\
**Created:** [August 19, 2008, 8:29pm UTC](https://forum.kirupa.com/t/removechild-error/268864 "2008-08-19T20:29:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![junkjeff](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@junkjeff](https://forum.kirupa.com/u/junkjeff)\
**Post date:** [August 19, 2008, 8:29pm UTC](https://forum.kirupa.com/t/removechild-error/268864/1 "2008-08-19T20:29:03Z")

</div>

I’ve been having trouble with removeChild lately. Below is a little project I made just to try stuff out.

btn.addEventListener(MouseEvent.CLICK, makepitcher);  
btn2.addEventListener(MouseEvent.CLICK, removepitcher);  
var mcClip:pitcher = new pitcher();

function makepitcher(event:MouseEvent):void{  
addChild(mcClip);  
mcClip.x=200;  
mcClip.y=200;  
}

function removepitcher(event:MouseEvent):void{  
if(mcClip){  
this.removeChild(mcClip);  
}  
}

I get the following error if I try to remove the pitcher without creating it first or if I created it and removed it already – ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.  
at flash.display::DisplayObjectContainer/removeChild()  
at Untitled\_fla::MainTimeline/removepitcher()
