为什么不能填充我的下拉菜单。 我在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>
答案 0 :(得分:0)
原因是您的结果是XML格式,并且您尝试在ArrayCollection中强制转换它。 您应该使用XMLListCollection类。