1 Reply Latest reply on Jan 24, 2011 9:31 AM by whiterrabbit

    dynamic filter function

    whiterrabbit Level 1

      I would like to be able to pass a dynamic item.property to the filter function.

       

      Hardcoding it like this works

       

      private function filterthis(item:Object):Boolean {

      if(item.companyname == _sortvalue)    // I don't want to hardcode the property of item

           {

           return true;    

           } else {

           return false;

           }

           }

       

       

       

      ----- but this is what I need ------

       

       

       

      private function filterthis(item:Object):Boolean {

      if(item._sortfield == _sortvalue)      // I tried passing in a string but it doesn't work

           {

           return true;    

           } else {

           return false;

           }

      }

       

       

      What is the proper way to pass the item.property of my array collection,

       

      Thanks