views:

222

answers:

2

If I send remote data from Zend_Amf to Flex, if two array properties on the object have the same data values they are deserialized at the remote end with the same memory storage.

Example: AS3 object:

Snippet:

[RemoteClass(alias="TestVO")]
public class TestVO
{
  public var test1:Array;
  public var test2:Array;
}

When this receives remote data from Zend_Amf server, if the array data are identical it allocates the same storage to the two arrays.

Eg: From remote (ZendAMF) object I send:

$this->test1 = array("foo", "bar");
$this->test2 = array("foo", "bar");

When I debug the TestVO object in Flex debugger I get:

test1 Array(@597d779)
test2 Array(@597d779)

ie: they reference the same array object.

If I send from the remote server slightly different values for the 2 arrays:

$this->test1 = array("foo", "bar");
$this->test2 = array("bar", "foo");

In the Flex debugger the TestVO object now has two seperate arrays as you'd expect:

test1 Array(@54cb7e9)
test2 Array(@54cb741)

AMF output looks Ok, it always sends two seperate values for test1/test2 even if they have the same values, so I'm guessing it's the way Flex de-serializes this?

Any ideas? Thanks.

+2  A: 

AMF does this to gain some compression over the wire. If you don't want this then you can switch to the AMF0 format instead of AMF3. But I'm not sure how to do that with ZendAMF.

James Ward
Thanks for the explanation.Looks like a bug on the Flash/Flex side - shouldn't the client create seperate data values on de-compression?
NigelF
A: 

Found bug ZF-7634 on Zend Framework implementation of AMF. It is serializing the arrays incorrectly.

http://framework.zend.com/issues/browse/ZF-7634

NigelF