# Flash CS3 AS3.0 removeChild Problem

**URL:** <https://forum.kirupa.com/t/flash-cs3-as3-0-removechild-problem/273511>\
**Category:** flash\
**Created:** [October 16, 2008, 10:25am UTC](https://forum.kirupa.com/t/flash-cs3-as3-0-removechild-problem/273511 "2008-10-16T10:25:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chr15athome](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@chr15athome](https://forum.kirupa.com/u/chr15athome)\
**Post date:** [October 16, 2008, 10:25am UTC](https://forum.kirupa.com/t/flash-cs3-as3-0-removechild-problem/273511/1 "2008-10-16T10:25:26Z")

</div>

Hi all,

I am new to the site but have looked through other posts and can’t find a solution to my problem.

I have a movie clip object (image gallery) that is loaded perfectly, but when I goto another part of my movie the object remains. I can do a stage.removeChild(???); in my button script which works. However when the gallery doesn’t exist I get an error message, how can I check if the object exists first:- i.e.

if(stage.getChildByName("???") != null){  
stage.removeChild(???);  
}

I have tried the code above but it never gets into the IF statement as the condition is never met. maybe “stage” should be something else but I add using stage.addChild(???);  
I presume the childs name will be its instance name, I have tried with and without quotes.

Can anyone suggest what might be wrong?

Thanks

Chris
