Count item count for ComboBox selected item : ComboBox Selection « Components « Flex






Count item count for ComboBox selected item

Count item count for ComboBox selected item
       
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.collections.*;
        
        private var myCursor:IViewCursor;

        public function countLast(theCursor:IViewCursor):int {
            var counter:int=0;
            var mark:CursorBookmark = theCursor.bookmark;
            while (theCursor.moveNext()) {
                counter++;
            }
            theCursor.seek(mark);
            return counter;
        }
        public function countFromSelection():void {
            myCursor.findFirst(myCB.selectedItem);
            var count:int = countLast(myCursor);
            ta1.text += myCursor.current.label + " at " + count;
        }
      
    </mx:Script>
    <mx:ArrayCollection id="myAC">
        <mx:Object label="A" data="AA" />
        <mx:Object label="B" data="BB" />
        <mx:Object label="C" data="CC" />
    </mx:ArrayCollection>
    <mx:ComboBox id="myCB" rowCount="7" dataProvider="{myAC}" change="countFromSelection();" />
    <mx:TextArea id="ta1" height="200" width="175" />
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Get selected value, state, capital and indexGet selected value, state, capital and index
2.Get selected item from ComboBoxGet selected item from ComboBox
3.ComboBox Selected IndexComboBox Selected Index
4.Count the number of items in a collection between the selected item in a ComboBox control and the end of the collection, and then returns the cursor to the initial locationCount the number of items in a collection between the selected item in a ComboBox control and the end of the collection, and then returns the cursor to the initial location
5.Select a new locale from the ComboBox control.
6.Load a resource module when the user selects the locale from the ComboBox control.