# Switch/Case Confusion

**URL:** <https://forum.kirupa.com/t/switch-case-confusion/318390>\
**Category:** flash\
**Created:** [January 18, 2011, 8:15pm UTC](https://forum.kirupa.com/t/switch-case-confusion/318390 "2011-01-18T20:15:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phatgreenbuds](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@phatgreenbuds](https://forum.kirupa.com/u/phatgreenbuds)\
**Post date:** [January 18, 2011, 8:15pm UTC](https://forum.kirupa.com/t/switch-case-confusion/318390/1 "2011-01-18T20:15:14Z")

</div>

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.

```auto

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;
  }
 }
}

```
