0

XML ファイルからコンボボックスに国を入力しようとしています。残念ながら、コンボボックスはいっぱいになりません。この問題を解決するにはどうすればよいですか? 前もって感謝します!

これが私のコードです:

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"/>
4

3 に答える 3

1

コードにエラーはありません。空のプロジェクトに貼り付けたところ、コンボボックスにフィールドが表示されました。

私が変更したのは、https ではなく http だけです。

したがって、問題はソース コードではなく、データのソースにあります。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>
于 2012-12-26T23:40:56.553 に答える
0

助けてくれてありがとう。

コードを新しいプロジェクトにコピーすることで解決しました。残念ながら、元のプロジェクトで何がうまくいかなかったのかわかりません。

于 2012-12-31T14:53:30.870 に答える
0

サービス呼び出しからの XML 応答がどのように見えるかを確認せずに、私が提案できる唯一のことは、resultFormatHTTPService「e4x」に設定することです。

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

これは、応答が XML であり、e4x 式を使用してデータを取得することを期待していることを HTTPService に伝えます。

于 2012-12-26T22:24:25.913 に答える