1 Reply Latest reply on Oct 28, 2008 2:45 PM by borfgordon

    Manually calling Menu.hide() within MenuBar results in exception on next show()

    borfgordon Level 1
      Hi,
      I have a MenuBar with the following data within it

      ROOT
      --CHILD1
      ----SubChild1-1
      ----SubChild1-2
      ----SubChild1-3
      --CHILD2
      --CHILD3
      ROOT2
      ROOT3

      When the mouse exits any Menu I execute a "menu.hide()" and the drop down menu disappears. When I click again on ROOT1 the menu shows again OK. I am detecting this by an item rollout event and detecting the mouse position relative to the menu box boundaries.

      This works fine when the menu data does not contain more than one level of children (i.e. no more than Child1, Child2 and Child3). However ONCE I introduce a second level of children (subchild1-1 etc) the MenuBar seems to break.

      For example, when the "subchild1-1, 1-2, 1-3" menu displays, when the mouse exits that menu I properly call "menu.parentMenu.hide()". However once I click again on ROOT1 I get the following error below. My question is why does calling menu.hide() when in context of a sub-menu, does the menubar break like this? Is there some state other than menu.hide() I must reset that is not documented?

      RangeError: Error #2006: The supplied index is out of bounds.
      at flash.display::DisplayObjectContainer/addChildAt()
      at mx.managers::SystemManager/ http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChildAt()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/managers/SystemManager.as:1687]
      at mx.managers::SystemManager/addChild()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/managers/SystemManager.as:1225]
      at mx.managers::PopUpManagerImpl/addPopUp()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/managers/PopUpManagerImpl.as:263]
      at mx.managers::PopUpManager$/addPopUp()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/managers/PopUpManager.as:169]
      at mx.controls::Menu/show()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/controls/Menu.as:1406]
      at mx.controls::MenuBar/showMenu()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/controls/MenuBar.as:1664]
      at mx.controls::MenuBar/mouseOverHandler()[/Applications/Adobe Flex Builder 3 Plug-in/sdks/3.1.0/frameworks/projects/framework/src/mx/controls/MenuBar.as:1756]


        • 1. Re: Manually calling Menu.hide() within MenuBar results in exception on next show()
          borfgordon Level 1
          Anyone have any ideas on this?

          I've also tried manually dispatching a MouseEvent.MOUSE_DOWN event outside of the Menu's visible area to simulate a "click" which triggers the Menu.mouseDownOutsideHandler() which cleans up the Menus. This works in almost all cases, however occasionally, when the mouse leaves the visible menu area, and the event is fired. I continue to get the stack trace as noted above. Resulting in a completely busted MenuBar system that requires the application to be restarted.

          Any ideas? What other "menubar" state needs to be adjusted when a drop down disappears?