I'm using Zend AMF to send my remote objects to Flex.
I've defined a Constant
class and created getASClassName()
method. Then I've created Action script class in flex.
Objects are send successfully, but they are deserialized to generic Objects
in Flex instead of specific ones.
EDIT: On network monitor in Flex I can see that AMF value is set to com.my.project.valueobjects.Constant
. Although array from event.result
contains Objects
.
What am I doing wrong?
Php declaration of class:
<?php
namespace Project\Entity;
class Constant
{
public $id;
public $name;
public $description;
public $value;
public function getASClassName(){
return 'com.my.project.valueobjects.Constant';
}
}
Class definition in flex:
package com.my.project.valueobjects{
[Bindable]
[RemoteClass(alias="Constant")]
public class Constant{
public var id:Number;
public var name:String;
public var description:String;
public var value:String;
}
Part of code handling Amf in php:
$server = new Zend_Amf_Server();
$server = $server->setClass("AmfService");
$server->setClassMap("com.my.project.valueobjects.Constant", "Constant");
Array of objects from php (dump made using print_r
):
[04-Mar-2012 14:23:08] Array
(
[0] => Project\Entity\Constant Object
(
[id] => 1
[name] => name
[description] => desc
[value] => 5
[_explicitType] => com.my.project.valueobjects.Constant
)