我有一個關於flex 4 remoteObjects的快速問題。 我想通過amfphp從MySql DB獲取信息到Flex 4.5。 我正在使用remoteobject標籤。我想使用結果屬性,但它似乎不適用於我。我究竟做錯了什麼?如何從remoteobject檢索結果AMFPHP Flex 4.5
如果我收集的信息形式數據庫沒有resulthandler它工作正常,但是當我想收集信息在arraycollection它不起作用。 arraycollection永遠不會充滿我檢索的信息。
This Works;
<?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="initApp()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:RemoteObject id="myRemote"
destination="solicitantService"
source="resume.solicitantService"
endpoint="http://localhost:8181/amfphp/gateway.php"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
private function initApp():void
{
myRemote.getUsers();
}
]]>
</fx:Script>
<mx:DataGrid id="myGrid" dataProvider="{myRemote.getUsers.lastResult}"/>
</s:Application>
而且這不起作用。
<?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="initApp()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<mx:RemoteObject id="myRemote"
destination="solicitantService"
source="resume.solicitantService"
endpoint="http://localhost:8181/amfphp/gateway.php"
result="myRemote_resultHandler(event)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var users:ArrayCollection = new ArrayCollection();
private function initApp():void
{
myRemote.getUsers();
}
protected function myRemote_resultHandler(event:ResultEvent):void
{
users = event.result as ArrayCollection;
}
]]>
</fx:Script>
<mx:DataGrid id="myGrid" dataProvider="{users}"/>
</s:Application>
我做錯了什麼?有人可以幫助解決這個問題嗎?我已經用spark和mx datagrid試了一下。
那麼我找到了解決方案。從Php我revieve陣列不ArrayCollection。