# Having trouble removing loaded child object b4 loading a new one

**URL:** <https://forum.kirupa.com/t/having-trouble-removing-loaded-child-object-b4-loading-a-new-one/327292>\
**Category:** Uncategorized\
**Created:** [February 19, 2012, 8:08pm UTC](https://forum.kirupa.com/t/having-trouble-removing-loaded-child-object-b4-loading-a-new-one/327292 "2012-02-19T20:08:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neil\_w2](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@neil\_w2](https://forum.kirupa.com/u/neil_w2)\
**Post date:** [February 19, 2012, 8:08pm UTC](https://forum.kirupa.com/t/having-trouble-removing-loaded-child-object-b4-loading-a-new-one/327292/1 "2012-02-19T20:08:13Z")

</div>

having trouble removing loaded child object b4 loading a new one

i can load a child object with this script if button is pressed:

[COLOR=#0000ff]mc\_char.btn\_darkangel.addEventListener(MouseEvent.CLICK, Response\_btn\_darkangel);[/COLOR]  
[COLOR=#0000ff]function Response\_btn\_darkangel(e:MouseEvent):void[/COLOR]  
[COLOR=#0000ff]{ [/COLOR]  
[COLOR=#0000ff] char\_image.text = “Dark-Angel.gif”;[/COLOR]  
[COLOR=#0000ff] char\_loader.load(new URLRequest(char\_image.text));[/COLOR]  
[COLOR=#0000ff]}[/COLOR]  
[COLOR=#0000FF]char\_loader[/COLOR][COLOR=#0000ff].contentLoaderInfo.addEventListener(Event.COMPLETE, startListener);[/COLOR]  
[COLOR=#0000ff]function startListener(e:Event):void[/COLOR]  
[COLOR=#0000ff]{[/COLOR]

[COLOR=#0000ff] MovieClip(root).mc\_display.mc\_portrait\_display.addChild([/COLOR][COLOR=#0000FF]char\_loader[/COLOR][COLOR=#0000ff].content);  
}[/COLOR]

and i can unload the child object with this script if clear button is pressed:

[COLOR=#0000ff]btn\_clear.addEventListener(MouseEvent.CLICK, Response\_btn\_clear);[/COLOR]  
[COLOR=#0000ff]function Response\_btn\_clear(e:Event):void[/COLOR]  
[COLOR=#0000ff]{[/COLOR]  
[COLOR=#0000FF]MovieClip(root).mc\_display.mc\_char\_display.removeChild(char\_loader.content);[/COLOR]  
[COLOR=#0000ff]}[/COLOR]

but having difficulty unloading child object when just that [COLOR=#0000FF]mc\_char.btn\_darkangel[/COLOR] button is pressed. Cause otherwise it just adds another instance then another and another and the different instances kinda pile ontop of each other

my question is how can i incorporate [COLOR=#0000ff]removeChild[/COLOR] script so that [COLOR=#0000FF]mc\_char.btn\_darkangel [/COLOR]doesn’t just pile instances of image ontop of each other
