0

Flex 4 の remoteObjects について簡単な質問があります。MySql DB から amfphp 経由で Flex 4.5 に情報を取得したいと考えています。remoteobject タグを使用しています。結果属性を使用したいのですが、うまくいかないようです。私は何を間違っていますか?

resulthandler を使用せずに DB から情報を収集すると正常に動作しますが、arraycollection で情報を収集したい場合は機能しません。arraycollection は、取得した情報で満たされることはありません。

これは機能します。

<?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>

私は何を間違っていますか?誰かがこれに出会うのを助けることができますか? 私はスパークとmxデータグリッドの両方で試しました。

さて、私は解決策を見つけました。Phpから、ArrayCollectionではなくArrayをrevieveします。

4

2 に答える 2

1

amfPHP は結果を ArrayCollection として返すのではなく、Array として返します。その部分を理解するのによくやった。

これは、本当に私を助けたコードへのリンクです。基本的な文字列から始まり、次にオブジェクト、(オブジェクトの) 配列です。

http://www.brentknigge.com/?q=node/499

于 2013-01-27T04:24:14.380 に答える