Created
May 23, 2013 08:31
-
-
Save amowu/5633521 to your computer and use it in GitHub Desktop.
Find ArrayCollection item by object attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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