# Populating comboboxes in Flex

**URL:** <https://forum.kirupa.com/t/populating-comboboxes-in-flex/251663>\
**Category:** flash\
**Created:** [February 11, 2008, 3:42pm UTC](https://forum.kirupa.com/t/populating-comboboxes-in-flex/251663 "2008-02-11T15:42:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![derm116](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@derm116](https://forum.kirupa.com/u/derm116)\
**Post date:** [February 11, 2008, 3:42pm UTC](https://forum.kirupa.com/t/populating-comboboxes-in-flex/251663/1 "2008-02-11T15:42:14Z")

</div>

Hi all,

I’m trying to populate a combobox in Flex with an xml repsonse I am getting over httpservice response!

[COLOR=red]\<?xml version=“1.0” encoding=“utf-8”?\>  
\<mx:Application xmlns:mx="[/COLOR][[COLOR=red]http://www.adobe.com/2006/mxml[/COLOR]](http://www.adobe.com/2006/mxml)[COLOR=red]" layout=“absolute” xmlns:comp=“components.\*” width=“460” height=“522” viewSourceURL=“srcview/index.html”\>  
\<mx:Script\>  
\<![CDATA[

```
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.http.HTTPService;
    import mx.utils.XMLUtil;
    import mx.collections.ArrayCollection;[/COLOR]

```

I’ve created an arraycollection  
[COLOR=red]//Array that holds the version name  
[Bindable]  
public var versionData:ArrayCollection ;[/COLOR]  
[COLOR=#ff0000][/COLOR]  
[COLOR=black]Have my HttpService method[/COLOR]  
[COLOR=red]/_Creates an HttpService object and executes the send method_/  
public function useHttpService():void {  
var params:Object = new Object() ;[/COLOR]  
[COLOR=red] //create an HTTPService object named service  
var service:HTTPService = new HTTPService();

```
         //set the properties of the service object
         service.url = "[/COLOR][[COLOR=red]http://localhost:9080/oneClickInstall/sample/XMLAppListAction[/COLOR]](http://localhost:9080/oneClickInstall/sample/XMLAppListAction)[COLOR=red]";  
         service.method="get";
         service.addEventListener("result", httpResult); 
         service.addEventListener("fault", httpFault);
         service.resultFormat="e4x";  
         service.send(params); } 

```

[/COLOR]

and have the following httpResult function

[COLOR=red]public function httpResult(event:ResultEvent):void {  
versionData = event.result.Version.Release.attributes() as ArrayCollection;[/COLOR]  
[COLOR=red]} //end function httpResult[/COLOR]

…

I then have a simple button which when pushed should populate a combobox

[COLOR=red]\<mx:Panel layout=“absolute” backgroundColor="#8396a9" borderStyle=“solid” left=“10” top=“10” width=“440” height=“391” cornerRadius=“20” borderThickness=“2” borderColor="#ffffff" id=“panel1”\>[/COLOR]  
[COLOR=red][/COLOR]  
[COLOR=red]\<mx:Button x=“20” y=“10” label=“Submit” click=“useHttpService()” id=“submitBtn”/\>[/COLOR]  
[COLOR=red][/COLOR]  
[COLOR=red]\<mx:ComboBox x=“165” y=“10” dataProvider="{versionData}" id=“versionBox” prompt=“Please select a version…”/\>[/COLOR]  
[COLOR=red][/COLOR]  
[COLOR=red]\</mx:Panel\>  
\</mx:Application\>[/COLOR]  
[COLOR=#ff0000][/COLOR]  
[COLOR=black]This doesn’t do anything? I was wondering if anyone would have any idea how I might get this to work or if there’s any examples of populating a combobox by adding an xml httpresponse to an arraycollection?[/COLOR]

Thanks a mil in advance for any help?

Cheers,  
Derm
