7 Replies Latest reply on Jan 5, 2011 9:00 AM by Ijimero

    Problems using ArrayCollection as DataProvider for both Tree and MenuBar, possibly bug?

    Ijimero

      Hi guys,

       

      I'm having some troble using a ArrayCollection as a DataProvider for both a Tree and a MenuBar...

       

      I've been reading some Adobe documentation about it, and i've read that both of the components read the dataProvider similarly.

       

      but my current DataProvider Works fine on Tree but not on the MenuBar component...

       

      my dataProvider consists on a ArrayCollection populated by a custom class (wich extends ArrayCollection), and among of its property is a children:ArrayCollection, so the the Hierarchy can be correctly read.

       

      when I use it on the Tree Component it works, but menuBar don't show me the branches...

       

      Can anyone help me?

       

      here's the function that create my dataprovider:

       


      private function fnFillDP():void{
                      for (var i:int = 0; admResult.length > i; i++){               
                          if (JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).nivel == 0){
                              var novoMenu:CL_ArrayMenu = new CL_ArrayMenu();
                              novoMenu.idMenu = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).idMenu;
                              novoMenu.titulo = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).titulo;
                              novoMenu.parent = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).parent;
                              novoMenu.nivel = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).nivel;
                              novoMenu.ordem = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).ordem;
                             
                              dataProvider.addItem(novoMenu);
                          } else if (JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).nivel == 1){
                              for (var j:int = 0; dataProvider.length > j; j++){
                                  if (CL_ArrayMenu(dataProvider[j]).idMenu == JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).parent){
                                      var novoMenuChildren:CL_ArrayMenu = new CL_ArrayMenu();
                                      novoMenuChildren.idMenu = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).idMenu;
                                      novoMenuChildren.titulo = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).titulo;
                                      novoMenuChildren.parent = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).parent;
                                      novoMenuChildren.nivel = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).nivel;
                                      novoMenuChildren.ordem = JV_MenuAdm(JV_AuxMenuAdm(admResult[i]).menuAdm[0]).ordem;
                                      if (dp.length > 0){
                                          if (CL_ArrayMenu(dp.getItemAt(0)).parent == novoMenuChildren.parent){
                                              dp.addItem(novoMenuChildren);
                                          } else {
                                              dp = new ArrayCollection();
                                              dp.addItem(novoMenuChildren);
                                          }
                                      } else {
                                          dp.addItem(novoMenuChildren);
                                      }
                                     
                                      CL_ArrayMenu(dataProvider[j]).children = dp;
                                      break;
                                  }
                              }
                          }
                      }
                      tree.dataProvider = dataProvider;
                      menu.dataProvider = dataProvider;
                  }

       

      sorry for bad english...