addChild on roll_over, removeChild on roll_out?

I’m having trouble getting this to work - I know the code must be wrong, but I can’t find the correct code anywhere. I want to have a movieClip pop up when a button is hovered, and disappear when the button is inactive.

If I delete the removeChild info, the roll_over function works.

chestnutPointe.addEventListener(MouseEvent.ROLL_OVER, goName);
chestnutPointe.addEventListener(MouseEvent.ROLL_OUT, dropName);


function goName (e:MouseEvent):void
{
	var chestnutName:cpName = new cpName();
	this.addChild(chestnutName);
	chestnutName.x = 0;
	chestnutName.y = 0;
}

function dropName (e:MouseEvent):void
{
	this.removeChild(chestnutName);
}

Try this


chestnutPointe.addEventListener(MouseEvent.ROLL_OVER, goName);
chestnutPointe.addEventListener(MouseEvent.ROLL_OUT, dropName);
var chestnutName:cpName = new cpName();

function goName(e:MouseEvent):void {
    this.addChild(chestnutName);
    chestnutName.x = 0;
    chestnutName.y = 0;
}

function dropName(e:MouseEvent):void {
    this.removeChild(chestnutName);
}

This works perfectly! Thank you!!

I had actually tried defining the var, but I guess I just wasn’t getting each piece right.

Thanks again!