# Add and removing Child from within a function problem

**URL:** https://forum.kirupa.com/t/add-and-removing-child-from-within-a-function-problem/269539
**Category:** flash
**Created:** [August 28, 2008, 6:17pm UTC](https://forum.kirupa.com/t/add-and-removing-child-from-within-a-function-problem/269539 "2008-08-28T18:17:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![junkjeff](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@junkjeff](https://forum.kirupa.com/u/junkjeff)
#### Post date: [August 28, 2008, 6:17pm UTC](https://forum.kirupa.com/t/add-and-removing-child-from-within-a-function-problem/269539/1 "2008-08-28T18:17:51Z")

</div>

I have the following function:

function textnumber(event:MouseEvent):void {  
//if any phone number fields are not filled  
if (area\_code.length != 3 || phone\_3.length != 3 || phone\_4.length!= 4){  
tb\_number.addChild(bad\_number);  
}

//if phone number fields are correct  
else{  
tb\_number.removeChild(bad\_number);  
}  
}  
The child is ADDED fine, but when the phone number fields are correct and the function executes, it should remove the “bad\_number” child. It doesn’t though, I’m wondering how within that function I can target the bad\_number child to get rid of it?
