# Problem with Switch/Case and nested Switch/Case

**URL:** <https://forum.kirupa.com/t/problem-with-switch-case-and-nested-switch-case/325680>\
**Category:** flash\
**Created:** [October 29, 2011, 8:51pm UTC](https://forum.kirupa.com/t/problem-with-switch-case-and-nested-switch-case/325680 "2011-10-29T20:51:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David56780](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@David56780](https://forum.kirupa.com/u/David56780)\
**Post date:** [October 29, 2011, 8:51pm UTC](https://forum.kirupa.com/t/problem-with-switch-case-and-nested-switch-case/325680/1 "2011-10-29T20:51:25Z")

</div>

Im trying to create a program that, depending on 2 variables, multiplies another variable by a static number. A friend suggested I use case/switch instead of if/else statements, which is what I was using before.

Here is the code:[INDENT]  
var a:String=String (OCC.text) [/INDENT]  
[INDENT]var b:String=String (DCC.text) [/INDENT]  
[INDENT]var c:Number=Number (ATC.text)  
[/INDENT]  
[INDENT=2]  
switch (a){  
[/INDENT]  
[INDENT=3]case ‘UM’:  
[/INDENT]  
[INDENT=4]switch (b){  
[/INDENT]  
[INDENT=5]case ‘AD’:  
[/INDENT]  
[INDENT=6]var ab:Number = new Number (c_1.0);  
[/INDENT]  
[INDENT=6]CA.text = String(ab);  
[/INDENT]  
[INDENT=6]break;  
[/INDENT]  
[INDENT=5]case ‘NC’:  
[/INDENT]  
[INDENT=6]var ac:Number = new Number (c_2.0);  
[/INDENT]  
[INDENT=6]CA.text = String(ac);  
[/INDENT]  
[INDENT=6]break;  
[/INDENT]  
[INDENT=5]case ‘KY’  
[/INDENT]  
[INDENT=6]var ad:Number = new Number (c_3.0);  
[/INDENT]  
[INDENT=6]CA.text = String (ad);  
[/INDENT]  
[INDENT=6]break;  
[/INDENT]  
[INDENT=4]}  
[/INDENT]  
[INDENT=3]case ‘AD’:  
[/INDENT]  
[INDENT=4]switch (b){  
[/INDENT]  
[INDENT=5]case ‘UM’:  
[/INDENT]  
[INDENT=6]var ba:Number = new Number(c_5.0);  
[/INDENT]  
[INDENT=6]CA.text = String(ac);  
[/INDENT]  
[INDENT=6]break;  
[/INDENT]  
[INDENT=5]case ‘NC’:  
[/INDENT]  
[INDENT=6]var bc:Number = new Number (c\*6.0);  
[/INDENT]  
[INDENT=6]CA.text = String (bc);  
[/INDENT]  
[INDENT=6]break;  
[/INDENT]  
[INDENT=5]default:  
[/INDENT]  
[INDENT=6]CA.text = “ABC”  
[/INDENT]  
[INDENT=3]}  
[/INDENT]  
[INDENT=2]}  
[/INDENT]

The problem is that when OCC is ‘UM’’ and DCC is ‘AD’ and ATC is 1, I get “ABC”. Im new to AS, so any help is much appreciated.
