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:
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