# Remove Child from Diferent Timeline

**URL:** <https://forum.kirupa.com/t/remove-child-from-diferent-timeline/311698>\
**Category:** flash\
**Created:** [July 14, 2010, 10:45am UTC](https://forum.kirupa.com/t/remove-child-from-diferent-timeline/311698 "2010-07-14T10:45:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![black\_pearl](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@black\_pearl](https://forum.kirupa.com/u/black_pearl)\
**Post date:** [July 14, 2010, 10:45am UTC](https://forum.kirupa.com/t/remove-child-from-diferent-timeline/311698/1 "2010-07-14T10:45:26Z")

</div>

How do I remove child from a different Timeline. One of my movieclip contains three children. I want to remove all the three children. How could I do that. I tried setting instance name and removing the instances using getChildByName. But it doesn’t seem to work.

```auto
var mainMc:MovieClip = new MovieClip();
addChild(mainMc);
var box:box_mc;

var objLength:int;
for (var i:int = 0; i<3; i++) {
    box= new box_mc;
    mainMc.addChild(box);
    box.x=i*100;
    box.name="box"+i;
    objLength=i;

}

remove_mc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
    for (var i:int=0; i<=objLength; i++) {
        mainMc.removeChild(getChildByName("box"+i));
    }
}

```
