0

I'm trying to fill a combobox with countries from a XML file. Unfortunately, the combobox does not get filled. How should I resolve this problem? Thanks in advance!

Here's my code:

protected function navigatorcontent2_creationCompleteHandler(event:FlexEvent):void
{
    fillCboCountries.addEventListener(ResultEvent.RESULT, fillCombobox);    
    fillCboCountries.send();        
}


protected function fillCombobox(event:ResultEvent):void
{           
    cboCountries.dataProvider=event.result.global.countryItem;              
}

<fx:Declarations>
<s:HTTPService id="fillCboCountries" url="https://marnixcoosemans2013.dreamhosters.com/scripts/countries_select.php"/>  
</fx:Declarations>  

<s:ComboBox id="cboCountries" x="10" y="414" width="173" labelField="countryLabel"/>
Sunil D.
  • 17,983
  • 6
  • 53
  • 65

3 Answers3

1

Your code has no errors. I have pasted it into my empty project and I see your fields in the combobox.

The only thing I have changed is http inspite of https.

So the problem is in the source of data, not in your source code! Try it without https.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           minWidth="955" minHeight="600" 
           creationComplete="navigatorcontent2_creationCompleteHandler(event)">

<fx:Declarations>
    <s:HTTPService id="fillCboCountries" url="http://marnixcoosemans2013.dreamhosters.com/scripts/countries_select.php"/>  
</fx:Declarations>  

<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;
        import mx.rpc.events.ResultEvent;

        protected function navigatorcontent2_creationCompleteHandler(event:FlexEvent):void
        {
            fillCboCountries.addEventListener(ResultEvent.RESULT, fillCombobox);    
            fillCboCountries.send();        
        }

        protected function fillCombobox(event:ResultEvent):void
        {           
            cboCountries.dataProvider=event.result.global.countryItem;              
        }
    ]]>
</fx:Script>

<s:ComboBox id="cboCountries" x="10" y="414" width="173" labelField="countryLabel"/>
</s:Application>
Anton
  • 4,544
  • 2
  • 25
  • 31
  • confirmed. `https://marnixcoosemans2013.dreamhosters.com/scripts/countries_select.php` is not available, however, it is opend with `http:`. – user1875642 Dec 27 '12 at 07:23
  • Thanks, the source is also available for me, but with a HTTP request in my code, i get this error: RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/scripts/countries_select.php?hostport=marnixcoosemans2013.dreamhosters.com&https=N&id=907E7DC4-A34C-188D-FC2E-DBAD7EE678DF"]. URL: http://marnixcoosemans2013.dreamhosters.com/scripts/countries_select.php"] – user1930785 Dec 27 '12 at 09:29
  • it can be a problem with security settings. It is an issue of the Flex sandbox. Usually a crossdomain.xml file helps. – Anton Dec 27 '12 at 09:35
0

Without seeing what the XML response from the service call looks like, the only thing I can suggest is to set the resultFormat on the HTTPService to "e4x":

<s:HTTPService id="fillCboCountries"
    url="https://marnixcoosemans2013.dreamhosters.com/scripts/countries_select.php"
    resultFormat="e4x" />

This tells the HTTPService that the response is XML and that you expect to get at the data using e4x expressions.

Sunil D.
  • 17,983
  • 6
  • 53
  • 65
0

Thank you all for the help.

I solved it by copying my code into a new project. Unfortunately, I have no idea what went wrong in the original project.