Search Flex Samples

Adding & removing elements from a List Control




list.jpg

<?xml version=”1.0″?>

<mx:Application xmlns:mx=” http://www.adobe.com/2006/mxml “>

<mx:Script>

<![CDATA[

import mx.collections.ArrayCollection;



[Bindable]

public var myAC:ArrayCollection = new ArrayCollection([”One”, “Two”, “Three”, “Four”]);

[Bindable]

public var myAC2:ArrayCollection = new ArrayCollection([”Ek”, “Do”, “Teen”, “Char”]);

]]>

</mx:Script>

<mx:List id=”lis” dataProvider=”{myAC}”/>

<mx:Button

label=”Add Element”

click=”myAC.addItem('new element');”/>

<mx:Button

label=”Remove Element”

click=”myAC.removeItemAt(lis.selectedIndex);”/>

<mx:Button

label=”Change ArrayCollection”

click=”myAC=myAC2″/>

</mx:Application>

0 comments:

Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples