Remove an item from list
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> 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); } </mx:Script> <mx:ArrayCollection id="myCollection" collectionChange="collectionChange(event)" /> <mx:TextInput id="myTextInput" /> <mx:List id="myList" dataProvider="{myCollection}" width="200" height="200" /> <mx:Button label="ADD" click="addItem()" /> <mx:Button label="REMOVE" click="removeItem()" /> <mx:TextArea id="myTextArea" width="200" height="200" /> </mx:Application>