# Beginner having problem with removechild() function

**URL:** <https://forum.kirupa.com/t/beginner-having-problem-with-removechild-function/320796>\
**Category:** flash\
**Created:** [April 1, 2011, 5:25pm UTC](https://forum.kirupa.com/t/beginner-having-problem-with-removechild-function/320796 "2011-04-01T17:25:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MortHamp](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@MortHamp](https://forum.kirupa.com/u/MortHamp)\
**Post date:** [April 1, 2011, 5:25pm UTC](https://forum.kirupa.com/t/beginner-having-problem-with-removechild-function/320796/1 "2011-04-01T17:25:44Z")

</div>

I’ve created a function that creates a thumbnail bar

function imageLoaded(evt:Event):void  
{  
var thumb:MovieClip = new MovieClip();  
//trace(thumb.x);  
thumb.y=710;  
addChild(thumb);  
thumb.name = gallery\_xml.image[currentImage].big;  
trace ("thumb "+thumb.name);  
thumb.x=currentImage\*thumbSpace;  
thumb.addEventListener(MouseEvent.CLICK, updateStage);  
thumb.addChild(evt.target.content);  
thumbDisplayed = true;  
currentImage++;  
}

What I want to do is when I navigate away from the page I want to remove the thumbnails from the page:

homeBT.addEventListener(MouseEvent.CLICK, ToHome);  
// function used to navigate to home page  
function ToHome (event:Event):void  
{  
if (thumbDisplayed = true)  
{  
removeChild(thumb);  
thumbDisplayed = false;  
}  
if (imageBigDisplayed = true)  
{  
removeChild(bigLoader);  
imageBigDisplayed = false;  
}  
}

However every time I try to use removeChild(thumb); it gives me this error:

Scene 1, Layer ‘actions’, Frame 16, Line 81 1120: Access of undefined property thumb.

I know it might be because thumb is inside a function but I haven’t been taught any other way to remove the movieclip.

Any help would be great! :}
