# removeChild 2ce -\> error

**URL:** <https://forum.kirupa.com/t/removechild-2ce-error/232941>\
**Category:** flash\
**Created:** [July 18, 2007, 9:15pm UTC](https://forum.kirupa.com/t/removechild-2ce-error/232941 "2007-07-18T21:15:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickjv](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@patrickjv](https://forum.kirupa.com/u/patrickjv)\
**Post date:** [July 18, 2007, 9:15pm UTC](https://forum.kirupa.com/t/removechild-2ce-error/232941/1 "2007-07-18T21:15:26Z")

</div>

I have a script which at some point MIGHT remove a child  
removeChild(obj[2]);

At the end of script I need another script which has to remove the child if it is still present. I thought that

```
if(obj[2]){
 removeChild(obj[2]);
}

```

would do the trick. But even if it’s removed in first part, then the second part still tries to remove it (it still sees obj[2] as TRUE) even though it already was removed from stage. Results in error

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

Am I doing something wrong here?
