4 Replies Latest reply on May 31, 2006 9:40 AM by andros

    Menubar and Checkboxes

    andros Level 1
      I am using a menubar with sub menus.
      Various submenu items utilize checkboxes.
      I would like to treat these check boxes much like a radio group in that when one is clicked to TRUE, the others are set to FALSE.

      Is there way to tell a specific menu item in a sub menu to set its checked value to false WHEN another item is clicked?
        • 1. Re: Menubar and Checkboxes
          zensoldier
          You just have to turn them all off every time one is selected.

          Say you have ten checkboxes and their instance name is box0 thru box9

          You can put code on the checkbox instance that turns off all of the rest or create a function that each ones calls that does the work for you.

          The function on the root is the way I would do it so here's how that would go.

          function doChecks(boxToCheck)
          {
          for(i=0;<=9;i++)
          {
          _root.["box" + i].setValue( false);
          }
          _root[boxToCheck].setValue( true);
          }

          then in the checkbox instance you would call the function

          on(release)
          {
          doChecks(this)
          }

          anyway, the moral of the story is that everytime one gets checked turn them all off then turn back on the one you want.

          Hope it helps
          • 2. Re: Menubar and Checkboxes
            andros Level 1
            Thanks for the reply.
            That would be good for the 'acting as a radioGroup' part of it.
            The problems is, how to change the status of the checkbox that inside a menu item.

            I load the static values of the menu item's checkboxes via XML like this:
            <menuitem label="Facilities" instanceName="facility_open" type="check" selected="false"/>

            Now to change the check to selected=false preferably without reloading the original XML data (thus reloading the menu).

            Any idear about this?
            • 3. Re: Menubar and Checkboxes
              Niumtep
              Finally something i think i can answer, i was messing around with this stuff aswell. I wanted to beable to destroy the object through multiple interfaces and one of them included directly from the menu as a click off function for the check menu item. Now this is what i found out, you don't need to change the actual xml, just use in-flash functions for the menu, like this:

              var Menu_item = _root.Your_menu.getMenuItemAt(2); //starts at 0 and goes on, remember seperators count aswell.
              _root.Your_menu.setMenuItemSelected(Menu_item, false); //the last true false = checked and not checked...

              Now an important note is that when using this method you need to re*get the handle on the menu_item, which is done first in my code example. Also to check if the item is checked i simply used boolean logic, everytime the button was checked, set the variable from the first to the second thing, at start its false, so do like this:

              if(your_boolean == false)
              {
              your_boolean = true;
              }else{
              your_boolean = false;
              }

              Hope this helps, if it was way off, sorry 'bout that.
              • 4. Re: Menubar and Checkboxes
                andros Level 1
                Thanks guys!

                That did the trick. A combination of efforts well appreciated.