This is probably really easy!
I have a program where kids can record the laps they run. Depending on how many laps, their level may increase. Level 1 has laps 1,2,3,4,5,6,7,8…Level 2 has laps 10, 11, 12, 13, 14, 14 etc. I have two vars. lapNumber = 1, and levelNumber = 1.
with a keyboard event, as laps increase lapNumber++, I need the levelNumber to check and possible go up. I was using a switch statement but Its not working. Maybe its with my syntax even though I’m not getting any compile errors. My trace statements are not tracing either. Maybe I should be programming this differently using arrays and I’ll change it if I have to. This is what I got. I also just realized my switch statements will always return a 1. I will have to add a && and another condition.
var lapNumber:Number = 1;
var levelNumber:Number = 1;
var distance:int = 15;
function increaseLevels():void{
lapNumber++
if (distance == 15)
{
switch (lapNumber)
{
case lapNumber > 0:
levelNumber = 1;
trace (levelNumber);
break;
case (lapNumber > 9):
levelNumber = 2;
trace (levelNumber);
break;
case lapNumber > 19:
levelNumber = 3;
trace (levelNumber);
break;
case lapNumber > 30:
levelNumber = 4;
trace (levelNumber);
break;
case lapNumber > 43:
levelNumber = 5;
trace (levelNumber);
break;
case lapNumber > 54:
levelNumber = 6;
trace (levelNumber);
break;
case lapNumber > 67:
levelNumber = 7;
trace (levelNumber);
break;
case lapNumber > 80:
levelNumber = 8;
trace (levelNumber);
break;
case lapNumber > 94:
levelNumber = 9;
trace (levelNumber);
break;
case lapNumber > 108:
levelNumber = 10;
trace (levelNumber);
break;
case lapNumber > 123:
levelNumber = 11;
trace (levelNumber);
break;
case lapNumber > 138:
levelNumber = 12;
trace (levelNumber);
break;
case lapNumber > 154:
levelNumber = 13;
trace (levelNumber);
break;
case lapNumber > 171:
levelNumber = 14;
trace (levelNumber);
break;
}
}