2 Replies Latest reply on Jan 19, 2010 1:45 AM by danny_run

    Enable/Desable MenuBar Item

    danny_run

      Hello i have a menu bar and i'm not able do dinamically enable/desable the submenu (menu2_2 for example - see code). I've found some examples on google but it seems that they only work with Flex 2 (i am using Flex 3 sdk). Can someone help with a concrete example? Thanks

       

      <mx:MenuBar id="myMenuBar" width="100%">
                  <mx:XMLList>
                      <menuitem label="menu1">
                          <menuitem label="menu1_1" open=""/>
                      </menuitem>
                      <menuitem label="menu2">
                           <menuitem label="menu2_1" open=""/>

                          <menuitem label="menu2_2" open=""/>
                       </menuitem>
               </mx:XMLList>

      </mx:MenuBar>

        • 1. Re: Enable/Desable MenuBar Item
          danny_run Level 1

          doesn't anyone know an answer

          • 2. Re: Enable/Desable MenuBar Item
            danny_run Level 1

            I have found a solution. It seems that if i define the XMlList outside the menu and i use it as the menu dataprovider like you can see in the code i can enable/desable the menu by setting up the enabled value with a bindable boolean (in the first case the enabled option didn't worked with a bindable variable only with: enabled="false" which didn't helped me cause i coudln't enable the menutiem back in):

             

             

            [Bindable]

             

            private var isEnabled:Boolean=false;

             

             

            <mx:XMLList id="myMenuList">

             

            <menuitem label="menu1">

             

            <menuitem label="menu1_1" open=""/>

             

            </menuitem>

             

            <menuitem label="menu2">

             

            <menuitem label="menu2_1" open=""/>

             

             

            <menuitem label="menu2_2" open="" enabled="{isEnabled}"/>

             

            </menuitem>

             

            </mx:XMLList>

             

             

            <mx:MenuBar id="myMenuBar" dataProvider="{myMenuList}" width="100%">

             

            </mx:MenuBar>