# addChild removeChild question

**URL:** https://forum.kirupa.com/t/addchild-removechild-question/256609
**Category:** flash
**Created:** [April 4, 2008, 2:08pm UTC](https://forum.kirupa.com/t/addchild-removechild-question/256609 "2008-04-04T14:08:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![webposer](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@webposer](https://forum.kirupa.com/u/webposer)
#### Post date: [April 4, 2008, 2:08pm UTC](https://forum.kirupa.com/t/addchild-removechild-question/256609/1 "2008-04-04T14:08:37Z")

</div>

All I am trying to do is remove a mute button from the stage that was created via addChild. For a flash flv player. After the cue point is reached, a replay button appears - at the same time removing the mute button.

Note: the addChild method for adding the mute button works just fine, but removing it throws: “Type Coercion failed: cannot convert MuteButton$ to flash.display.DisplayObject.”

code:

```auto
function addButton(object) {
        addChild(new object());
}

function removeButton(object) {
        removeChild(object);
}

mMatt.addEventListener(
  MetadataEvent.CUE_POINT,
  function(evt:MetadataEvent):void {
    
    if (evt.info.name == "test") {
        mMatt.seek(0);
        addButton(replay);
        removeButton(MuteButton);
    }
    
  }
);

addButton(MuteButton);

```

Any help is much appreciated.
