private function findInCollection(c:ArrayCollection, findFunction:Function):Array { var matches : Array = c.source.filter( findFunction ); return matches; } private function findFunction(propertyName:String,propertyValue:*):Function { return function( element : *, index : int, array : Array ) : Boolean { return element[propertyName] == propertyValue; } } Call the function:
var searchedElements:Array=findInCollection(ac,findFunction('recordId',2));
No comments:
Post a Comment