8 Replies Latest reply on May 19, 2009 7:55 AM by DigitalSpeciaist

    grab filtered items from ArrayCollection after filterFunction

    DigitalSpeciaist

      This is an easy one. I have my filtering function, but instead of using the main ArrayCollection after it has been filtered, I want to grab all the filtered items and pass them into another ArrayCollection.

       

       

      private var allScreens:ArrayCollection;

      [Bindable]
      private var filteredScreens:ArrayCollection;

       

      private function filterFunc(value:Object):Object
                  {
                      if(Number(value.module_number) == 1)

                          {
                          return true;
                           }
                      return false;
                  }

       


              private function filterSuff(value:Object=null):void
                  {
                  allScreens.filterFunction = filterFunc;
                  allScreens.refresh();
                 
                   for(var i:int =  0; i<allScreens.length; i++)
                       {
                       if (allScreens.getItemAt(i).module_number == 1)    {
                           filteredScreens.addItem(allScreens.getItemAt(i).filename);
                       }
                      }
                 
                  trace (ObjectUtil.toString(filteredScreens));
                  }