4 Replies Latest reply on May 17, 2007 11:33 AM by Josh Johnson

    Retrieving state from menubar check item

    Josh Johnson Level 1
      So I see that menubar items may be defined as type="check", meaning that it behaves like a checkbox with a boolean state.

      <menuitem label="Foo" type="check" toggled="true" />

      My problem is that I can't seem to figure out how to reference this object to extract it's state. In the case of the radio type, it's straight forward where the declaration includes a groupName attribute for retrieving the value. Is there something similar that can be done to get the boolean state of a check type item?
        • 1. Re: Retrieving state from menubar check item
          BLXWebMaster Level 1
          Not sure what you are using to capture the Click Event, however this is one example. You need to access the toggle atrtibute.

          private function menuHandler(event:MenuEvent):void {
          <!--
          Alert.show(XML(event.item).toXMLString(), "DEBUG");
          Alert.show("Label: " + event.item.@label + "\n" +
          "Data: " + event.item.@data, "Clicked menu item");
          -->
          Alert.show(event.item.@toggled);
          }
          • 2. Re: Retrieving state from menubar check item
            Yoshihama
            So if I'm understanding you right, the value can only be accessed during the clickEvent on the menu? If that's the case, it seems like I'll need to create another boolean variable that stores the value and gets updated on the clickEvent. Kind of a pain, but I guess it works. Thanks for the help.
            • 3. Re: Retrieving state from menubar check item
              BLXWebMaster Level 1
              Can you be a little morse specific as to exactly what you are trying to accomplish. Are you trying to store all the values for any menu items that have checks that has been clicked during the life of the application?

              • 4. Re: Retrieving state from menubar check item
                Josh Johnson Level 1
                So I think I've got it, but here's a quick rundown...

                I have a titleWindow component that includes a menubar with a checkbox setting. The titleWindow also includes other components that must reference the checkbox setting and do different things based on the value. So what I did was to create a new variable that stores the menu checkbox toggle state and is updated everytime the state is changed. Then my components can query the boolean variable to determine the actions they are to perform. So far so good.