# removeChild other thread

**URL:** <https://forum.kirupa.com/t/removechild-other-thread/277869>\
**Category:** flash\
**Created:** [December 18, 2008, 10:10am UTC](https://forum.kirupa.com/t/removechild-other-thread/277869 "2008-12-18T10:10:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kubson](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@Kubson](https://forum.kirupa.com/u/Kubson)\
**Post date:** [December 18, 2008, 10:10am UTC](https://forum.kirupa.com/t/removechild-other-thread/277869/1 "2008-12-18T10:10:58Z")

</div>

Hello everybody!

I was reading similar threads but i didnt find out solution for my problem.  
First i would like to give u a piece of code:

```auto

var btn:Btn;
var xPos:Number = 0;

for (var i:uint=0;i<2;i++)
{
	if(i==0)
	{
		xPos=0;
	}
	else
	{
		xPos+=120;
	}
	btn = new Btn();
	btn.x = xPos;
	//btn.name="btn"+i;
	stage.addChildAt(btn, i);
	
btn.addEventListener(MouseEvent.CLICK, clickBtn);

}

var checker:Number=0;
var curX:Number;

function clickBtn(e:Event)
{
var dispObj:DisplayObject = e.currentTarget as MovieClip;
var currentBtn:Number = stage.getChildIndex(dispObj);

var s:Sprite = new Sprite();
s.graphics.beginFill(0x000000,0.8);
s.graphics.drawRect(0,0,150,50);
s.graphics.endFill();
s.x=e.currentTarget.width+5;
var obj:DisplayObject = s;

//curX=s.width+5;

e.currentTarget.addChild(s);

if(checker==0)
{
	++checker;
	moveBtn(stage.getChildAt(1));

}
else
{
	--checker;
	stage.getChildAt(currentBtn-1).removeChild(s);
	moveBtnBack(stage.getChildAt(1));
}

}

```

The question is how can I remove child from other object but as u see i’m going to get this object by getChildAt method.

```auto
stage.getChildAt(currentBtn-1).removeChild(s);

```

this parts of code doesn’t work.

I’ll appreciate all kind of help 🙂

Have a nice day!
