Rambling Developer

Recent Posts


Archives


Flex Dictionary Serialization

adminadmin

Just ran across an interesting issue with the serialization of Dictionaries to Java when targeting Flash 9 as opposed to Flash 10.

When targeting Flash 9, a remote object call, which passes a Dictionary as a parameter, would be correctly serialized and then deserialized as a Map on the Java side. This is not true with Flash 10!

When targeting Flash 10, a remote object call, which passes a Dictionary as a parameter, would NOT be correctly serialized and then deserialized as a Map on the Java side.

To be fair, it seems that Adobe has never officially supported serializing the Dictionary class and has recommended using an Object instead. So, to solve my problems, instead of sending a Dictionary as a parameter to my remote object calls, I now send an Object.

To be clear, I have switched the creation of my Dictionary from:

<p>var dictionary:Dictionary = new Dictionary();</p>
<p>dictionary["one"] = 1;</p>
<p>dictionary["two"] = 2;</p>

to:

<p>var object:Object = new Object();</p>
<p>object["one"] = 1;</p>
<p>object["two"] = 2;</p>

With that simple change everything serializes correctly again and I can correctly pass Maps to and from the server.

Lesson learned: Never use something that is not officially supported by Adobe and then expect it to work correctly when targeting new versions of the Flash Player!

Comments 0
There are currently no comments.