import mx.events.CollectionEventKind;
import mx.events.CollectionEvent;
import mx.collections.SortField;
import mx.collections.Sort;
import mx.collections.ArrayCollection;
private var index:Number = 0;
public function collectionChange(event:CollectionEvent):void
{
switch (event.kind)
{
case CollectionEventKind.ADD:
myTextArea.text += "Item Added\n";
break;
case CollectionEventKind.REPLACE:
myTextArea.text += "Item Replaced\n";
break;
case CollectionEventKind.REMOVE:
myTextArea.text += "Item Removed\n";
break;
}
}
public function addItem():void
{
myCollection.addItem({label: myTextInput.text, data: index});
index++;
}
private function removeItem():void
{
if (myList.selectedItem != null)
myCollection.removeItemAt(myList.selectedIndex);
}