Flash 9 Object Serialization Note

It wasn't clear from docs exactly what gets serialized when an object is saved or sent so I thought I would share what I found.

  1. Any public instance variable.
  2. Any state accessible via matching public get/set method pair.

Read-only properties are not serialized. Why is obvious but unnecessarily leaky class design is the price to pay in practice. A related problem is that Event subclass can't be serialized without implementing IExternalizable because the 'type' property is read-only.

Overriding type property in Event subclass conflicts with internal dispatchEvent implementation which apparently ignores the overriden value, causing events to be  dispatched using the internal type. A workaround is to clone the serialized event before dispatching. Not pretty but this enables events to flow across systems, a requirement of mine.