0

为什么不能填充我的下拉列表。我在http://www.adobe.com/devnet/flex/videotraining.html做视频。值不在nameSaleChoose.how 中。请帮我。

我想在下拉菜单中显示 LocalDesc。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="320" height="480" 
    creationComplete="initApp()">
<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.controls.Alert;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import spark.events.IndexChangeEvent;
        [Bindable]
        private var nameSaleChoose:ArrayCollection;
        protected function service_resultHandler(event:ResultEvent):void
        {
            // TODO Auto-generated method stub  
            nameSaleChoose = event.result as ArrayCollection;
        }
        private function initApp():void
        {
            service.GetXml("SELECT PositionCode,LocalDesc 
                   FROM StaffPosition WHERE PositionCode IN ('00000','00021')");
        }
    ]]>
</fx:Script>
<fx:Declarations>
    <s:WebService id="service" 
                  wsdl="http://192.168.1.25/service.asmx?wsdl" 
                  result="service_resultHandler(event)"
                  > 
    </s:WebService>
</fx:Declarations>
<s:DropDownList id="dropDownList" x="35" y="38" width="164" 
     dataProvider="{nameSaleChoose}" labelField="LocalDesc">
</s:DropDownList>

此 xml:从 Web 服务返回

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
  www.w3.org/2001/XMLSchema-instance">
<soap:Body>
 <GetXmlResponse xmlns="http://tempuri.org/">
  <GetXmlResult>
    <NewDataSet xmlns="">
      <Table>
        <PositionCode>00000</PositionCode>
        <LocalDesc>Administrator</LocalDesc>
      </Table>
      <Table>
        <PositionCode>00021</PositionCode>
        <LocalDesc>saleman</LocalDesc>
      </Table>
     </NewDataSet>
    </GetXmlResult>
  </GetXmlResponse>
</soap:Body>
</soap:Envelope>
4

1 回答 1

0

原因是您的结果是 XML 格式,并且您尝试将其转换为 ArrayCollection。您应该使用 XMLListCollection 类。

于 2012-06-05T12:47:40.433 回答