removeChild other thread

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:


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.

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

this parts of code doesn’t work.

I’ll appreciate all kind of help :slight_smile:

Have a nice day!