# How to reference a child

**URL:** https://forum.kirupa.com/t/how-to-reference-a-child/292989
**Category:** flash
**Created:** [July 21, 2009, 7:22pm UTC](https://forum.kirupa.com/t/how-to-reference-a-child/292989 "2009-07-21T19:22:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ricky55](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@Ricky55](https://forum.kirupa.com/u/Ricky55)
#### Post date: [July 21, 2009, 7:22pm UTC](https://forum.kirupa.com/t/how-to-reference-a-child/292989/1 "2009-07-21T19:22:30Z")

</div>

Got this code

```auto

function onOver (event:MouseEvent):void
{
	var panel:MovieClip = new storePanel();
	addChild(panel);
	panel.x = event.target.parent.x + -25;
	panel.y = event.target.parent.y + -128;
	panel.alpha=0;
	TweenLite.to(panel, .7, {alpha:1, ease:Sine.easeOut});
	panel.storeText_txt.text = walesArray[buttonArray.indexOf(event.target)];
}

function onOut (event:MouseEvent):void
{
	removeChildAt(this.numChildren-1);
}

```

Firstly removeChildAt(this.numChildren-1); is working but is this the best way of removing the child?

More importantly, in the onOut function I want to tween out the panel object but I don’t seem to be able to reference panel. For instance even if I said panel.alpha = 0; I get an error, why is this? and how can I talk to my newly created panel movie clip in the onOut function.

Thanks guys, I know I’ve asked loads recently but I’m really getting into my AS. I know I don’t know much but I’m really wanting to learn more!
