Im trying to save some classes into the shared object and load them back but I get
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed.
Im trying to save some classes into the shared object and load them back but I get
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed.
What type do you get instead? Type.getClass
, etc?
When I load the classes back it says they are “objects” but there were saved as “myclass”.
Are you saving the whole SharedObject as a class type? What if you attach class instances as fields to a generic data object as the shared object, and save and restore that? Perhaps that will work differently?
thanks.
I save like this :
var testInstance = new TestClass();
var SO = SharedObject.getLocal ("mySharedObject");
SO.data.instance = testInstance;
SO.flush ();
I also tried this if this is what you mean :
var testInstance = new TestClass();
var genericObject = {instance:testInstance};
var SO = SharedObject.getLocal ("mySharedObject");
SO.data.genericObject= genericObject ;
SO.flush ();
either way the type of the class becomes “Object @fcee9d1” for eg.
I think you might have to do some trace statements within openfl.net.SharedObject
to get a better idea what’s going on. We should be using local storage, as well as Haxe serialization to store the values. When we unserialize, we have a custom class resolver to handle some remapping of object types, but otherwise Haxe class serialization/deserialization should be supported