Header Ad

Monday, May 5, 2014

How to apply filterFunction to Array Collection in Adobe Flex or Action Script ?

The following is an example that will show you how to apply a fiterFunction to array collection in action script.

var idsList:ArrayCollection=new ArrayCollection(["1","2","3"]);
var nodeId:Number = 2;

var filterByIdFilter:Function = function(item:Number):Boolean
{
    if(item == nodeId) return true;
    return false;
}
idsList.filterFunction = filterByIdFilter;
idsList.refresh();


If the provided nodeId matches with idsList array collection, after applying filterFunction the idsList will be truncated to size "1", otherwise size "0".

No comments: