2 Replies Latest reply on May 15, 2012 1:07 AM by Madhav Subedi

    passing arguments to a function

    BosDog

      Hi this is probably something easy someone can help with. I'm calling the below function "FilterFunction" and it works well in this code:

       

      private function filterTheater():void {

      dataArray.filterFunction = FilterFunction;

      dataArray.refresh() ;

       

      msc_addItemHandler(event,'filterResourceType','resourceTypeF')

       

      // rebuild filters

       

      }

      private function FilterFunction(item:Object):Boolean {

      // theater filter - loops all selected items in theater combo and checks if rows match criteria

      for each (var t:Object in theatreF.selectedItems) {

      if (item.THEATER == t.data && t.assigned) {

      return true ;

      }

      }

      return false ;

      }

       

      However once I want to add an additional argument for FilterFunction to accept I don't know how to pass in the item:Object as it was already happening before without me needing to specify it in an argument. Once i add another argument I then need to supply 2 arguments. Here is the changed (and problematic) code:

       

      private function filterTheater():void {

      dataArray.filterFunction = FilterFunction('theater');

      dataArray.refresh() ;

       

      msc_addItemHandler(event,'filterResourceType','resourceTypeF')

       

      // rebuild filters

       

      }

      private function FilterFunction(item:Object, filterWhat:String):Boolean {

      // theater filter - loops all selected items in theater combo and checks if rows match criteria

      for each (var t:Object in theatreF.selectedItems) {

      if (item.THEATER == t.data && t.assigned) {

      return true ;

      }

      }

      return false ;

      }