0 Replies Latest reply on Jul 28, 2009 2:15 AM by kris456

    Disabling MenuBar Item

    kris456

      I have a MenuBar Control which has a XMLList as the data provider.

       

      The XML List is:

      private var menubarXML:XMLList =
                      <>
                          <menuitem label="Menu1" data="top">
                              <menuitem label="MenuItem 1-A" data="1A"/>
                              <menuitem label="MenuItem 1-B" data="1B"/>
                          </menuitem>
                          <menuitem label="Menu2" data="top">
                              <menuitem label="MenuItem 2-A" type="check"  data="2A"/>
                              <menuitem type="separator"/>
                              <menuitem label="MenuItem 2-B" >
                                  <menuitem label="SubMenuItem 3-A" type="radio" 
                                      groupName="one" data="3A" toggled="true"/>
                                  <menuitem label="SubMenuItem 3-B" type="radio"
                                      groupName="one" data="3B"/>
                              </menuitem>
                          </menuitem>
                      </>;
      

       

      The Menu bar control is

       <mx:MenuBar id="men" labelField="@label" itemClick="menuHandler(event);" 
                  dataProvider="{menuBarCollection}"  width="100%" />
                              
      
      

       

       

      I wanted to disable a submenu Item in on of the menu when user clicks button. So inorder to achieve it I created a function

       

      private function enableSubMenuItem (posMenuBar:int, posSubItem:int, bool:Boolean) : void
               {
                  var menu:XML = XML (menuBarCollection.getItemAt(posMenuBar));
                  menu.node[posSubItem].@enabled = bool;
               }

       

       

      Then I called the function enableSubMenuItem in the function which is invoked when the button is clicked by

       

      enableSubMenuItem(0, 1, true);
      

       

      But when I click I get the following sandbox error at the line :

       

      menu.node[posSubItem].@enabled = bool; (in the function  enableSubMenuItem)

       

      TypeError: Error #1010: A term is undefined and has no properties.

       

      Why could this be so ?

      Please Help me resolve the issue.