A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: case statement prob

  1. #1
    disco monkey monkeysquid's Avatar
    Join Date
    Jan 2003
    Location
    Glasgow - the armpit of the north.
    Posts
    306

    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.

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    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.

  3. #3
    disco monkey monkeysquid's Avatar
    Join Date
    Jan 2003
    Location
    Glasgow - the armpit of the north.
    Posts
    306
    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.

  4. #4
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center