Flex AMFPHP and VO’s (RemoteObjectAMF0 update)

Posted on July 25, 2006 | 8 comments

[lang_en]
Thanks to the help of some people on the Flex coders list, I have been able to update the RemoteObjectAMF0 class with some examples of how to use AMFPHP and PHP/AS VO’s. I got this to work with PHP 5.1.1 and PHP 4.3.11.

There was a few things that I learned how to do in the process. First was in Flex and AS3 you can define the object type of an ArrayCollection by using [ArrayElementType("com.renaun.samples.vo.BookVO")].

[code lang="javascript"]
[ArrayElementType("com.renaun.samples.vo.BookVO")]
public var books:ArrayCollection;
[/cc]

To make the BookVO.php work in PHP 4 just change the "public" identifiers to "var".

There are now 2 examples in the RemoteObjectAMF0 package. The first is the updated Cairngorm login example (see in action / source).

The new example I created is a non-Cairngorm AMFPHP example (see in action / source ).

Also note that I have changed the namespace to be "com.renaun." instead of "com.multispan.".

Thanks to Robert Was for providing me partial code.

[update]
The registering of the remote class in AS was not done properly. I need to use [RemoteClass(alias="com.renaun.samples.vo.BookVO")] not the old registerClass method. Thanks to Andrea for that tip.

The code examples have been updated so when you click on an item in the datagrid it display the name in a label field. This demonstrates the class mapping working.
[/lang_en]
[lang_zh]
由Flex Coders List的一些人, 我能够更新换代 Remote Object AMFO,给几个怎么用AMFPHP和PHP/AS
VO的例子。用PHP 5.1.1和PHP 4.3.11可以做得到。

在过程中我学到一些事情。其一,
在Flex和AS3用[ArrayElementType("com.renaun.samples.vo.BookVO")]
你能定义ArrayCollection的object type。

[code lang="javascript"]
[ArrayElementType("com.renaun.samples.vo.BookVO")]
public var books:ArrayCollection;
[/cc]

为了在PHP 4用BookVO.php你需要把"public"改到"var"。

现在Remote Object AMFO包有两个例子。第一个是更新换代的Cairngorm注册例子 (例子/代码程序)。

我刚创造的是一种non-Cairngorm AMFPHP的例子 (例子/代码程序)。

注意, 我改namespace到 "com.renaun."不是原来的 "com.multispan."。

感谢Robert Was, 他给我代码程序的一部分。

[更新换代]

.
AS Remote class的登录做错了。必得用[RemoteClass(alias="com.renaun.samples.vo.BookVO")],
别用以前的registerClass的方法。感谢Andrea的注意。

我有更新换代代码的例子, 所以按数据网项目的时候他会在label field把名字表现出来。
[/lang_zh]

  • http://www.thoughtfaqtory.com Simon Barber

    Thats awesome Renaun. My next challenge is to try and get Class Mappings to work with CakePHP.

  • http://manuelsaintvictor.com diamondtearz

    Thank you for that. I was able to get some results back from my server with it and extend it to add an image for each book. That’s the first time I clearly understood the nature of the server-side value objects in AMFPHP.

  • http://www.renaun.com Renaun Erickson

    Simon, do you have some sample code I can play with in CakePHP to help with?

    Diamond, Glad to here it help.

  • Pingback: Renaun Erickson

  • Marcelo Serpa

    Awesome work Renaun.

    @Simon: I´m also trying to do that… currently I´m still experimenting. Get to #cakeamfphp when you´ve got the time!

    Cheers,

    Marcelo.

  • http://blog.insnet.de Fabian

    the sample doesnt work :-(

    You are using your API Service in the services.mxml

  • http://www.renaun.com Renaun Erickson

    The “Services.mxml” has “http://localhost/amfphp1_2/gateway.php” defined, you need to replace it with your own gateway location. Is there something more specific that has an issue?

  • Dan Van Brunt

    Does your RemoteObjectAMF0 work with Flex 3?
    I’m getting the error:
    “VerifyError: Error #1053: Illegal override of RemoteObjectAMF0 in com.renaun.rpc.RemoteObjectAMF0.

    param count mismatch
    virt params=3 optional=1 mx.rpc::AbstractService/setCredentials()
    over params=2 optional=0 mx.rpc::AbstractService/setCredentials()

    When I look in the language ref for flex 2 and flex 3 I noticed that the AbstractService class has a different number of parameters for 2 vs 3.

    What are my options here?

  • http://www.renaun.com Renaun Erickson

    Change the setCredential method code to the following in RemoteObjectAMF0.as

    override public function setCredentials( username:String, password:String, charset:String = null ):void
    {
    gateway_conn.setCredentials( username, password, charset );
    }

  • Pingback: Flex with PHP « It’s all about RIA

  • Pingback: Fx-PHP « Flex Generation Weblog

  • Pingback: Quick Links for Technology :: Adobe Flex :: With PHP « Mjcprasad’s Blog