我正在使用Zend AMF從PHP應用程序中提取一些數據。不過,我無法將數據綁定到簡單的DropDownList控件。 PHP方法是:無法將數據綁定到Flex 4中的DropDownList控件
class Test
{
public function myMethod()
{
$res = array();
$res[] = array('NAME' => 'ThisIsATest', 'ID' => 1);
return $res;
}
}
網絡監視器報告該方法正在返回結果。它返回以下爲數組:
下面是Flex代碼:
<?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="500" height="286"
creationComplete="initApp()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
private function myMethodResult(e:ResultEvent):void
{
searchType.dataProvider = e.result as ArrayCollection;
}
protected function initApp():void
{
service.myMethod();
}
protected function faultHandler(event:FaultEvent):void
{
trace(event.fault.faultString);
}
]]>
</fx:Script>
<fx:Declarations>
<s:RemoteObject id="service"
destination="zend"
source="Test"
showBusyCursor="true"
fault="faultHandler(event)">
<s:method name="myMethod" result="myMethodResult(event)"/>
</s:RemoteObject>
</fx:Declarations>
<s:DropDownList id="searchType" labelField="NAME"/>
</s:WindowedApplication>
任何幫助將不勝感激。提前致謝。
當你把'var a:Array = e.result as Array; trace(a.length,a [0],a.join());'在行上面''propertyList.dataProvider = e.result as Array;' – Amarghosh 2010-09-08 13:27:20
我在兩種方法下運行; myMethod = 1,另一個方法= 528。 – Reado 2010-09-08 13:41:35