# removeChild help please :)

**URL:** <https://forum.kirupa.com/t/removechild-help-please/276364>\
**Category:** flash\
**Created:** [November 26, 2008, 7:26am UTC](https://forum.kirupa.com/t/removechild-help-please/276364 "2008-11-26T07:26:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxray](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@maxray](https://forum.kirupa.com/u/maxray)\
**Post date:** [November 26, 2008, 7:26am UTC](https://forum.kirupa.com/t/removechild-help-please/276364/1 "2008-11-26T07:26:09Z")

</div>

Hi I have been trying to get my head around AS3 having been used to 2.0 and am having a bit of an issue with the removal of dynamic movie clips. My script grabs a list of items from xml and displays them but when I click a different title to get another list the previous list remains. I cant seem to work out where to fit in the removeChild. Can anyone help?

Here is the code I am using:

```auto
import flash.display.MovieClip; import flash.events.MouseEvent;
client.addEventListener(MouseEvent.CLICK, onClickHandler);
media.addEventListener(MouseEvent.CLICK, onClickHandler);
client.buttonMode = true; 
client.useHandCursor = true; 

	function onClickHandler(myEvent:MouseEvent){
		trace(myEvent.target.name);
		if (myEvent.target.name == "client"){
			getSubcats ("clientid", "imag_clients");

		}
		if (myEvent.target.name == "media"){
			getSubcats ("mediaid", "imag_mediatype");

		}
		
		}
		

		media.buttonMode = true; 
media.useHandCursor = true; 

function getSubcats ($thetype,$thetable){
	
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
 
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
 
xmlLoader.load(new URLRequest("http://www.imaginate.uk.com/version_07/select.php?type="+$thetype+"&table="+$thetable));

function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseClients(xmlData);

}
 
function ParseClients(clientInput:XML):void {
var clientList:XMLList = clientInput.entry;
var startX = 12;
var startY = 70;
var yPos = 70;
var xPos = 12;
var totalWidth = 0;

	for each (var clientElement:XML in clientList) {
	var newClient:client_holder = new client_holder();
	newClient.clientName.text = clientElement.name;
	newClient.clientName.autoSize = "left";
	newClient.x = xPos ;
	newClient.y = yPos;
	totalWidth = totalWidth + newClient.width +2;
	yPos = yPos + newClient.height;
			trace(newClient.name);
	addChild(newClient);
	}

}
	}

```

If anyone can help it would be well appreciated 🙂
