I have no idea why this is not working…the last block (case “0”) should check for and remove whichever of the two boxs that are currently onstage but for some reason its only removing one and ignores the other.
cbs3.addEventListener(Event.CHANGE, doit3);
var NP3_mc:NPM = new NPM();
var AP3_mc:APM = new APM();
function doit3(event:Event):void {
switch (cbs3.selectedItem.data){
case "1":
//trace("1");
if (addChild(AP3_mc)){
removeChild(AP3_mc); //if the AP exists lets get rid of it
addChild(NP3_mc);
} else {
addChild(NP3_mc);
}
break;
case "2":
//trace("2");
if (addChild(NP3_mc)){
removeChild(NP3_mc); //if the NP exists lets get rid of it
addChild(AP3_mc);
} else {
addChild(AP3_mc);
}
break;
case "0": //this should check for and remove whichever of the previous two are on the stage.
//trace("0");
if (addChild(NP3_mc)){
removeChild(NP3_mc);
break;
} else if (addChild(AP3_mc)){
removeChild(AP3_mc);
break;
}
}
}