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.
Adam
2010-06-03 20:32:16
why? won't object deserialization be faster in AS3 that JSON decoding?
Ceilingfish
2010-06-03 20:35:07
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
2010-06-03 20:36:19
AMF will be, in my experience, both faster and easier.
David Wolever
2010-06-03 20:37:09
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
2010-06-03 20:46:30
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
2010-06-04 17:34:43
+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
2010-06-03 20:36:30
If you can tell me how the data is getting into Flex, I might be able to offer some more help.
David Wolever
2010-06-03 20:37:30