# RemoveChild if exists

**URL:** <https://forum.kirupa.com/t/removechild-if-exists/283226>\
**Category:** flash\
**Created:** [March 3, 2009, 10:11pm UTC](https://forum.kirupa.com/t/removechild-if-exists/283226 "2009-03-03T22:11:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pardoner](https://avatars.discourse-cdn.com/v4/letter/p/5daacb/32.png) [@pardoner](https://forum.kirupa.com/u/pardoner)\
**Post date:** [March 3, 2009, 10:11pm UTC](https://forum.kirupa.com/t/removechild-if-exists/283226/1 "2009-03-03T22:11:41Z")

</div>

I’d like to remove a child of the display list if it exists before adding another to the stage. This gives me Error the first time I call it because ‘myMC’ doesn’t exist.

```auto

function callMc(){
 if(myMc) removeChild(myMc);
 myMc = new MyMc( newParams);
 addChild(myMc);
}

```

Is there a better way of doing it?
