# FRUSTRATED: getChildByName() not working, please help

**URL:** <https://forum.kirupa.com/t/frustrated-getchildbyname-not-working-please-help/302681>\
**Category:** Uncategorized\
**Created:** [January 5, 2010, 6:52pm UTC](https://forum.kirupa.com/t/frustrated-getchildbyname-not-working-please-help/302681 "2010-01-05T18:52:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cry4dawn](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@cry4dawn](https://forum.kirupa.com/u/cry4dawn)\
**Post date:** [January 5, 2010, 6:52pm UTC](https://forum.kirupa.com/t/frustrated-getchildbyname-not-working-please-help/302681/1 "2010-01-05T18:52:59Z")

</div>

Hey guys, I hope someone here can help me figure this out. I have a movie that loads a head and a body onto the stage. I want to send it a command to delete the existing load different heads and bodies.

Heres what I have and in theory would like to do:

```auto

function loadItem(itemPath:String, itemType:String) {
 var mLoader:Loader = new Loader();
 var mRequest:URLRequest = new URLRequest(itemPath + ".swf");
 mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(evt:Event){onLoadItem(evt,itemType,itemPath)});
 mLoader.load(mRequest);
}
 
function onLoadItem(loadEvent:Event,itemType:String,itemPath:String){  
  
  loadEvent.currentTarget.content.instanceName = itemType;
  
  if(itemType=="B") {
   removeChild(getChildByName("B"));
   addChild(loadEvent.currentTarget.content);
   loadEvent.currentTarget.content.x = 0;
   loadEvent.currentTarget.content.y = 225;
  }else{
   removeChild(getChildByName("H"));
   addChild(loadEvent.currentTarget.content);
   loadEvent.currentTarget.content.x = 0;
   loadEvent.currentTarget.content.y = 0;   
  }
}
 
loadItem("head path", "H");
loadItem("body path", "B");
 

```

I am missing something. If I trace the instanceName it shows B or H but getChildByName(“B”) or getChildByName(“H”) returns NULL. Can someone please help me out here? Thanks
