PDA

View Full Version : Add an item to a list.


diego.gomes
06-07-2006, 07:15 PM
Hi,

I would like to know how can I make a function that adds the selected combo box element to a list component, when I click on a button. I tried the MyFirstFlexApp example but it doesn't work.

Thankx!

nirth
06-18-2006, 01:07 PM
Hi,

I would like to know how can I make a function that adds the selected combo box element to a list component, when I click on a button. I tried the MyFirstFlexApp example but it doesn't work.

Thankx!
try this one

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalAlign="middle" horizontalAlign="center" layout="vertical">
<mx:Script>
<![CDATA[
[Bindable]
private var comboDP:Array = [{label:'label:a',data:0},{label:'label:b',data:1}, {label:'label:b',data:2},
{label:'label:d',data:3},{label:'label:e',data:4}, {label:'label:f',data:5},
{label:'label:g',data:6},{label:'label:h',data:7}, {label:'label:i',data:8},
{label:'label:j',data:9}];
[Bindable]
private var listDP:Array = new Array();
private function onComboChange():void
{
listDP.push(comboDP[combo.selectedIndex]);
list.dataProvider = listDP;
}
]]>
</mx:Script>
<mx:ComboBox id="combo" dataProvider="{comboDP}" change="onComboChange();" />
<mx:Spacer height="50" />
<mx:List dataProvider="{listDP}" id="list" />
</mx:Application>

but i have some problem with binding data, list component does not want to update it...but it can be used as simplest example