|
-
Trainee coder
[RESOLVED] [HELP] 'switch' statement limit (???)
Hey everyone,
I'm in need of some quick help for something that's baffling me atm. So basically I've got my game set up so that upon completing a level a function which runs a 'switch' statement to create the next level. Something along these lines:
PHP Code:
function createLevel (lvlnum:Number):Void {
createWorld();
switch (lvlnum) {
case 1:
// stuff would happen here to create lvl 1
break;
case 2:
// stuff would happen here to create lvl 2
break;
// repeat this process until there are 20 lvl cases
}
//do general to run each time a new lvl is created (like reset scores, rest lives, etc.)
}
So what's baffling me is that all of a sudden when I tried to add the 20th case (the 20th level) I got an error in FlashDevelop telling me "This file is not a valid AS2.0 class". I tried to compile the file in Flash and it said it couldn't do it with an error of something alonmg the lines of "couldn't compile .swf... please check if the file is a read-only or if it is being used by another application".
None of that made sense, so I restarted the computer when I got back home. I still get the error in FlashDevelop of an invalid AS2 class, but now Flash compiles the game fine (without an error).. but wait there's more. The bast*rd works all the way to the 19th level, but when it hits the 20th lvl (and attempts to run the 20th case) it doesn't run the case. The 'next level' button seems to work fine (I've run some traces) but using the debugger and traces I've found not only does the switch function not run, but some variables become undefined. Now, it's possible that these variables would be losing their values because the switch statement isn't being fired properly, but there's so much random crap and errors going on I've got no idea why this could've occurred (especially considering I’m 95% sure that the only change I made to the code when this happened was adding another case/level).
So unless someone understands the error message from FlashDevelop, I'm thinking AS has a limit of how many cases one switch statement can handle; but when I delete the 20th case, I still get this error from FD!.. So yeah, I'm completely lost, I'm trying to stick to a close deadline on this game and so any help would be brilliant to hear atm.
Cheers,
Viza.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|