PDA

View Full Version : [AS3] how to assign combobox value dynamically using arraycollection?


kotecha_rohit
10-30-2009, 04:08 PM
Hi All,

I am getting list of java objects from database. which is list of city.

I have created one action script file City which includes cityId , cityName.

Now i want to map that java city object list to actionscript list but i am not getting how to do this.

Below is code :

public var cityList:ArrayCollection;

private function cityListHandler(event:ResultEvent):void{

cityList = event.result as ArrayCollection;

addContForm.cityList.dataProvider = cityList as City;
addContForm.cityList.labelField = "cityName";
}

In above code addContForm is Form component. and cityList is combobox.

I want to fill comobobox dynamically based on event.

Any help would be greatly appreciated.
Thanks and regards,
Rohit kotecha.

henke37
10-30-2009, 04:45 PM
What did you need us to do again?

kotecha_rohit
11-02-2009, 07:41 AM
I am developing one small demo application. In that i have created one action script class named City which has two fields. cityId, cityName and i have also mapped this class with my backend java class City using tag RemoteClass.
at Java side City class contains same fields as in actionscript city class.

City.as file listed below.

package
{
[Bindable]
[RemoteClass(alias="flex.addressbook.City")]
public class City
{
private var cityId:int;
private var cityName:String;
}
}

Means how can i create ArrayCollection or list of actionscript objects of City class to hold list of city which is return from backend code in java.?

Thanks,
Rohit