# Switch/case help

**URL:** <https://forum.kirupa.com/t/switch-case-help/129611>\
**Category:** Uncategorized\
**Created:** [November 25, 2004, 9:40pm UTC](https://forum.kirupa.com/t/switch-case-help/129611 "2004-11-25T21:40:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadbuttrue](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sadbuttrue/32/908_2.png) [@sadbuttrue](https://forum.kirupa.com/u/sadbuttrue)\
**Post date:** [November 25, 2004, 9:40pm UTC](https://forum.kirupa.com/t/switch-case-help/129611/1 "2004-11-25T21:40:07Z")

</div>

I’m making a countdown timer, and I want different events to be triggered at different stages of the time. I’m using getTimer to calculate how long is left to an arbitrary finishtime.

The problem I am having is I am trying to use the switch/case command to trigger the events. All that happens, even when elapsedTime goes beyond the required time, is that it goes the default clause. Any idea how I can use ranges of numbers within the case clauses?

[font=Courier New]\_root.onEnterFrame = function() {  
currentTime = getTimer();  
elapsedTime = Math.round((finishTime - currentTime)/1000);  
switch (elapsedTime) {  
case elapsedTime\<=0 :  
trace(“finished”);  
case elapsedTime\<=10 :  
trace(“10 seconds to go”)  
case elapsedTime\<=60 :  
trace(“less than one minute”);  
default:  
trace(“long way to go yet”)  
}  
countdownTime.text = Math.floor(elapsedTime/60) + “:” + elapsedTime%60;  
}[/font]
