Bind Array to List and change Array to update the List : List Data « Components « Flex






Bind Array to List and change Array to update the List

Bind Array to List and change Array to update the List
           
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        
            import mx.collections.ArrayCollection;
            
            [Bindable]
            public var myArray:Array = ["A", "B", "C"];
            
            public function addCountryToArray(country:String):void
            {
                myArray.push(country);
            }
            
      
    </mx:Script>
    
    <mx:TextInput id="countryTextInput" text="D" />
    
    <mx:Label text="Bound to Array" />
    <mx:Button click="addCountryToArray(countryTextInput.text)" label="Add Country to Array" />
    <mx:List dataProvider="{myArray}" width="200" />
    
    
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using an ArrayCollection to drive the display of a List componentUsing an ArrayCollection to drive the display of a List component
2.Fill Array of Object into ListFill Array of Object into List
3.Embedded Object Array into ListEmbedded Object Array into List
4.List with string array collectionList with string array collection
5.List With Hard Coded ArrayList With Hard Coded Array
6.Use static string list as data for ListUse static string list as data for List
7.List component that displays icons specified in the dataList component that displays icons specified in the data
8.List with dataProviderList with dataProvider
9.Two List definitions with and without dataProvider tagTwo List definitions with and without dataProvider tag
10.Lists of Complex DataLists of Complex Data
11.List cell editor data fieldList cell editor data field
12.A List control that displays data items represented by String dataA List control that displays data items represented by String data
13.Spark List without data providerSpark List without data provider
14.A List control where each data item is represented by an Object with three fieldsA List control where each data item is represented by an Object with three fields
15.List DataProviderList DataProvider
16.HorizontalList DataProviderHorizontalList DataProvider