Skip to content

Instantly share code, notes, and snippets.

@amowu
Created May 23, 2013 08:31
Show Gist options
  • Select an option

  • Save amowu/5633521 to your computer and use it in GitHub Desktop.

Select an option

Save amowu/5633521 to your computer and use it in GitHub Desktop.
Find ArrayCollection item by object attribute.
var ac:ArrayCollection = new ArrayCollection();
ac.addItem({id:1, name:'Amo', age:'26'});
ac.addItem({id:2, name:'Octocat', age:'16'});
ac.addItem({id:3, name:'Koala', age:'26'});
var sort:Sort = new Sort();
sort.fields = [new SortField('id'), new SortField('age')];
ac.sort = sort;
ac.refresh();
var cursor:IViewCursor = ac.createCursor();
if (cursor.findFirst({id:1, age: 26}))
{
trace(cursor.current.name); // Amo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment