views:

157

answers:

2

I have an array that I am constructing in PHP which I am serializing then returning to Flex through AMFPHP. Can someone point me towards a solution for unserilizing said data once it gets into Flex via ActionScript 3?

A: 

You might want to look into using JSON encoding rather than serializing.

Encode JSON in PHP

Decode JSON in ActionScript 3

Adam
why? won't object deserialization be faster in AS3 that JSON decoding?
Ceilingfish
Seems like a viable solution since AMFPHP supposedly serializes it's data for compressed transport. I'll give JSON encoding a shot - Thanks for the help.
Peter Hanneman
AMF will be, in my experience, both faster and easier.
David Wolever
AMFPHP in it's current iteration is not capable of returning an array directly from PHP. It has the ability to return numbers, strings and record sets, but not arrays.
Peter Hanneman
Peter that is not true. You most certainly can return an array from php to as3 via amfphp. David Wolever has the right idea with using a RemoteObject to handle automatic deserialization.
Tempname
+1  A: 

There are basically two ways. If you use something like the RemoteObject class, they will be automatically deserialized. This is how I prefer to do things. However, if all you've got is a ByteArray if serialized objects, you can use the read{Object,Int,...} methods to read the data it contains.

David Wolever
If you can tell me how the data is getting into Flex, I might be able to offer some more help.
David Wolever