Mega Code Archive

 
Categories / Flex / Components
 

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>