flash as3 - stack overflow error in case / switch statement
Wow - I'm kind of excited - I get a stack overflow error. I'm not sure why though...
This is my code:
switch (direction) {
case "left" :
if (project_array[cp].projectThumb.thumbActive == false){
if (cp>0){ cp--; }
checkActive("left")
开发者_高级运维 } else {
unloadProject();
}
break;
case "right" :
if (project_array[cp].projectThumb.thumbActive == false){
if (cp<(tp-1)){ cp++; }
checkActive("right")
} else {
unloadProject();
}
break;
}
It's due to a compiler bug, normally you can avoid it enclosing your case content with {} =>
switch (direction) {
case "left" :
{ // --> here
if (project_array[cp].projectThumb.thumbActive == false){
if (cp>0){ cp--; }
checkActive("left")
} else {
unloadProject();
}
} // -> and here
break;
case "right" :
{ // --> here
if (project_array[cp].projectThumb.thumbActive == false){
if (cp<(tp-1)){ cp++; }
checkActive("right")
} else {
unloadProject();
}
} // -> and here
break;
}
I'm not sure if this was a bug at the time of the last response, but as of today it's considered a code convention in flex:
http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions
精彩评论