topical media & game development
professional-flex-code-06-SortCollections.mx
professional-flex-code-06-SortCollections.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.SortField;
import mx.collections.Sort;
import mx.collections.ArrayCollection;
[Bindable]
public var myCollection:ArrayCollection = new ArrayCollection
(
[
{label: "A"},
{label: "B"},
{label: "C"},
{label: "D"},
{label: "E"}
]
);
public function sortCollection():void
{
var sort:Sort = new Sort();
sort.fields = [new SortField("label", true, true)];
myCollection.sort = sort;
myCollection.refresh();
}
]]>
</mx:Script>
<mx:List dataProvider="{myCollection}" width="200" />
<mx:Button label="Sort Collection" click="sortCollection()" />
</mx:Application>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.