-
disco monkey
case statement prob
k, i've checked the macromedia site for an explanation of the case and by what i've read this should work. however, it's not.
can anyone see any errors within?
Code:
switch (_root.user_access) {
case 1 :
_root.main_menu = 5;
_root.sub_menu = 5;
break;
case 2 :
_root.main_menu = 5;
_root.sub_menu = 4;
break;
case 3 :
_root.main_menu = 5;
_root.sub_menu = 0;
break;
}
thx.
-
Senior Member
I don't see anything nothing wrong with that, as this works as expected:
Code:
_root.user_access = 2;
switch (_root.user_access) {
case 1 :
_root.main_menu = 5;
_root.sub_menu = 5;
break;
case 2 :
_root.main_menu = 5;
_root.sub_menu = 4;
break;
case 3 :
_root.main_menu = 5;
_root.sub_menu = 0;
break;
}
trace("_root.main_menu=" + _root.main_menu); //5
trace("_root.sub_menu=" + _root.sub_menu); //4
So could be a targetting problem with your variables?
Last edited by chi-styler; 02-19-2005 at 07:22 PM.
-
disco monkey
hey chi. cheers for replying so fast.
just worked it out. for some reason i have tu use:
case "1";
instead of:
case 1;
not sure why it's not interperateing a number, only string.
cheers.
-
Senior Member
Oh right, that variable must be set/created as a String at some point then. If you're bringing it in from an external source, text file for example, everything defaults to a String.
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
|