# Remove child with button

**URL:** <https://forum.kirupa.com/t/remove-child-with-button/325925>\
**Category:** flash\
**Created:** [November 11, 2011, 10:30pm UTC](https://forum.kirupa.com/t/remove-child-with-button/325925 "2011-11-11T22:30:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucgeme](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@lucgeme](https://forum.kirupa.com/u/lucgeme)\
**Post date:** [November 11, 2011, 10:30pm UTC](https://forum.kirupa.com/t/remove-child-with-button/325925/1 "2011-11-11T22:30:52Z")

</div>

Hello,  
Please see the picture for better explanation. Every time i click “add new table” btn, i create new MC. Now i wish to remove any MC from stage… When i click either “Masa1”, “Masa2”… and so on, then “delete table” btn, the target MC is removed.  
How do I do that?  
Here is the code so far

```auto
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;

stop();
addTable_btn.addEventListener(MouseEvent.CLICK, addNewTableListener);
var i:uint = 1;
function addNewTableListener(e:MouseEvent):void
{
    var table:Table = new Table();
    table.tableName.text = "Masa" + i;
    table.name = "masa" + i;
    i++;
    addChild(table);
    table.x = Math.random() * (stage.stageWidth-table.width);
    table.y = 200;

    table.addEventListener(MouseEvent.MOUSE_DOWN, startDragListener);
    stage.addEventListener(MouseEvent.MOUSE_UP, stopDragListener);

    //addtable_btn.removeEventListener(MouseEvent.CLICK, addNewTableListener);

    function startDragListener(e:MouseEvent):void
    {
        e.target.startDrag();
        
    }
    function stopDragListener(e:MouseEvent):void
    {
        stopDrag();
    }

}

```
