2 Replies Latest reply on Sep 8, 2010 9:44 AM by Flex harUI

    Out of the bounds with a MenuBar

    BatistutaGab

      Hello,

       

      I've a quite strange error. I've created my own MenuBar like this :

      <mx:XMLList id="menuData">
              <menuitem label="File">
                  <menuitem label="New file (ctrl+n)" action="newFile"/>
                  <menuitem label="Save (ctrl+s)" action="save"/>
                  <menuitem label="Save all (ctrl+shift+s)" action="saveAll"/>
              </menuitem>

      </mx:XMLList>

      <mx:MenuBar  labelField="@label" dataProvider="{menuData}"  itemClick="menuAction(event)" width="100%" />

       

      And the function that apply the right code for each item is :

      protected function performAction(action:String):void{
                      trace("performa action");
                      switch(action) {
                          case "newFile":
                              if (this.mainTabNav != null) { //create the popUp window to ask the name of the new graph
                                  var window:NewGraphTitleWindow = new NewGraphTitleWindow();
                                  window.addEventListener(CloseEvent.CLOSE,newGrapgWindowClosedHandler,false,0,true);
                                  PopUpManager.addPopUp(window,this,true);
                                 
                              }
                              else {
                                  this.newGraphWindowClosedHandler(null);
                              }
                             
                              return;
                          case "save":
                              return;
                          case "saveAll":
                              return;
                          default :
                              return;
                      }       
      }

       

      Everything work correctly. However, if I click 3 times on the menu item "newFile", after the third time I've this error :

      RangeError: Error #2006: L'index indiqué sort des limites.
          at flash.display::DisplayObjectContainer/addChildAt()
          at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::rawChildren_addChildAt()[C:\autobuild\3.5.0\fr ameworks\projects\framework\src\mx\managers\SystemManager.as:2179]
          at mx.managers::SystemChildrenList/addChild()[C:\autobuild\3.5.0\frameworks\projects\framewo rk\src\mx\managers\SystemChildrenList.as:111]
          at mx.managers::PopUpManagerImpl/addPopUp()[C:\autobuild\3.5.0\frameworks\projects\framework \src\mx\managers\PopUpManagerImpl.as:309]
          at mx.managers::PopUpManager$/addPopUp()[C:\autobuild\3.5.0\frameworks\projects\framework\sr c\mx\managers\PopUpManager.as:169]
          at com.?????.ui.workflow::WorkflowEditor/performAction()[/Users/?????/FLEX/Taches/?????/REPO SITORY/src/com/?????/ui/workflow/WorkflowEditor.mxml:194]
          at com.?????.ui.workflow::WorkflowEditor/menuAction()[/Users/?????/FLEX/Taches/?????/REPOSIT ORY/src/com/?????/ui/workflow/WorkflowEditor.mxml:184]
          at com.?????.ui.workflow::WorkflowEditor/___WorkflowEditor_MenuBar1_itemClick()[/Users/????? /FLEX/Taches/?????/REPOSITORY/src/com/?????/ui/workflow/WorkflowEditor.mxml:334]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9440]
          at mx.controls::MenuBar/eventHandler()[C:\autobuild\3.5.0\frameworks\projects\framework\src\ mx\controls\MenuBar.as:1400]
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9440]
          at mx.controls::Menu/dispatchEvent()[C:\autobuild\3.5.0\frameworks\projects\framework\src\mx \controls\Menu.as:1319]
          at mx.controls::Menu/mouseUpHandler()[C:\autobuild\3.5.0\frameworks\projects\framework\src\m x\controls\Menu.as:1692]

       

      It's very strange. Do you have any idea about a solution?

       

      Many thanks

       

      Bat