BladePoint
BladePoint

Reputation: 632

Saving custom class /w object to local SharedObject

I have a custom class that I have been saving to a local SharedObject with no problems after using registerClassAlias.

registerClassAlias("MyClass",MyClass);

MyClass's variables are all private, and I read that private variables are not serialized unless they use explicit setters and getters, which fortunately MyClass uses for all private variables. Now I want to add another private variable to MyClass - a generic object:

private var myObject:Object = new Object();

The problem is that I can't use explicit setters and getters with myObject if I want to do something like:

myObject["day"] = "Monday";

And because the private variable myObject doesn't use setters and getters, nothing in myObject is retrievable when MyClass is loaded. It turns out that the easiest fix is to make myObject public instead of private and everything works. But I was wondering what would be the right way to keep myObject private and have it serialize properly?

Upvotes: 0

Views: 243

Answers (1)

moosefetcher
moosefetcher

Reputation: 1901

Use a ByteArray as described here.. http://jacksondunstan.com/articles/1642

Upvotes: 0

Related Questions