Skip to content

Instantly share code, notes, and snippets.

@doronkatz
Created April 15, 2011 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doronkatz/921072 to your computer and use it in GitHub Desktop.
Save doronkatz/921072 to your computer and use it in GitHub Desktop.
ArrayCollection FilterFunction in-line
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.collections.SortField;
import mx.collections.Sort;
import mx.collections.ArrayCollection;
[Bindable]
private var catFamilyAC:ArrayCollection;
[inject]private var model:ModelController;
private function init():void {
var cat:CATDTO;
/* Initialize and populate the ArrayCollection object. */
catFamilyAC = new ArrayCollection();
for each (var cat:CatDTO in model.otherArraySourceAC) {
catFamilyAC.addItem(cat);
}
}
...
/** As you can see, inline, I have added a function rather than having to add another function to link it up to */
/** this one filters for duplicate cat_ids **/
private function filterAC():void {
catFamilyAC.filterFunction = function(item:CatDTO):Boolean{
return cats[item.CAT_ID] ? true : false;
}
}
...
]]>
</mx:Script>
...
</mx:Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment