CollectionEventKind.REMOVE : Collection Event « Data Model « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Data Model » Collection EventScreenshots 
CollectionEventKind.REMOVE
CollectionEventKind.REMOVE
        
<?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>

   
    
    
    
    
    
    
    
  
Related examples in the same category
1.CollectionEventKind.ADD, CollectionEventKind.REMOVE, CollectionEventKind.REPLACE, CollectionEventKind.UPDATECollectionEventKind.ADD, CollectionEventKind.REMOVE, CollectionEventKind.REPLACE, CollectionEventKind.UPDATE
2.CollectionEventKind.ADDCollectionEventKind.ADD
3.CollectionEventKind.REPLACECollectionEventKind.REPLACE
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.