# Switch/Case - driving me mad! Help!

**URL:** <https://forum.kirupa.com/t/switch-case-driving-me-mad-help/122856>\
**Category:** Uncategorized\
**Created:** [September 17, 2004, 5:09pm UTC](https://forum.kirupa.com/t/switch-case-driving-me-mad-help/122856 "2004-09-17T17:09:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerb\_UK](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gerb_uk/32/396_2.png) [@Gerb\_UK](https://forum.kirupa.com/u/Gerb_UK)\
**Post date:** [September 17, 2004, 5:09pm UTC](https://forum.kirupa.com/t/switch-case-driving-me-mad-help/122856/1 "2004-09-17T17:09:53Z")

</div>

Hi,

I’ve attached a .fla

Basically, I want to press a button (either button 1 or button 2). Each button press sets a variable to either 1 or 2 and then plays a movie clip. Halfway through the movie clip being played, something occurs (in this case, just a trace) depending on the value of the variable managed by the ‘switch’ command.

I’ve used switch/case script, but I cannot for the life of me work out why it’s not working!

Script on buttons:

Button 1

on (release) {  
test = 1;  
circle.gotoAndPlay(2);  
}

Button 2

on (release) {  
test = 2;  
circle.gotoAndPlay(2);  
}

Script on frame 10 of ‘circle’

switch (test) {  
case 1 :  
trace(“button one”);  
break;  
case 2 :  
trace(“button two”);  
break;  
default :  
trace(“neither”);  
}

Whateverm button I press returns ‘neither’ in the trace?

Help!
