# Remove movieClip dynamically

**URL:** <https://forum.kirupa.com/t/remove-movieclip-dynamically/269891>\
**Category:** flash\
**Created:** [September 2, 2008, 7:42pm UTC](https://forum.kirupa.com/t/remove-movieclip-dynamically/269891 "2008-09-02T19:42:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixel\_chick](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@pixel\_chick](https://forum.kirupa.com/u/pixel_chick)\
**Post date:** [September 2, 2008, 7:42pm UTC](https://forum.kirupa.com/t/remove-movieclip-dynamically/269891/1 "2008-09-02T19:42:26Z")

</div>

I have a map that I created to display some results of a small town election. There is a statsBox movieClip that pops up on mouseOver on each county that displays the results pulled from an XML file. The statsBox is on the stage and I am dynamically creating a movieClip (named candidate) that goes inside of it that lists the candidate, percentage and so on. As I move around the map, the info for each county gets placed on top of the info from the previous county. How do I remove each instance of candidate on mouseOff? This is my code:

function showBox(e:MouseEvent):void {  
var raceList:XMLList = xmlData.row.(AreaNum == areaNum && RaceID == 484);  
for (var n:uint = 0; n\<raceList.length(); n++) {  
newCandidate = new candidate();  
addChild(newCandidate);  
newCandidate[‘candidateName’].text = raceList[n].calcCandidate;  
newCandidate[‘votes’].text = Math.round(raceList[n].calcCandidatePercentage_100) + “%”;  
newCandidate[‘bar’].width = (Math.round(raceList[n].calcCandidatePercentage_100));  
newCandidate.y =changex;//set the x pos of the thumb to the changex var  
changex = changex+newCandidate.height;  
statsBox.addChild(newCandidate);  
}//end for  
}//end showBox

function hideBox(e:MouseEvent):void {  
Tweener.addTween(e.currentTarget[‘inside’], {alpha:1, time:.5, transition:“linear”});  
statsBox.visible = false;  
}//end hideBo
