I know it is a simple matter to store Strings and Numbers with a SharedObject, and I am also familiar with this sort of thing:
var sharedObject:SharedObject = SharedObject.getLocal("userData");
var obj:Object = new Object();
obj.prop = "value";
sharedObject.data.userobj= obj;
sharedObject.flush();
However, I am attempting to store an object of the class GameStage, a class I have defined to hold data about stages in my game. This type of thing doesn't seem to be working:
var sharedObject:SharedObject = SharedObject.getLocal("userData");
var stageOne:GameStage = new GameStage();
stageOne.highScore = 99999;
sharedObject.data.stageOne = stageOne;
sharedObject.flush();
This code doesn't throw an error, but when I try to retrieve the stage data later, like so:
stageOne = sharedObject.data.stageOne;
I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert Object@3d220629 to GameStage.
I guess my question is: exactly what sort of data types can be stored in a SharedObject? Everywhere I've looked online has answered that question with "anything that can be used in Flash", which isn't very descriptive – obviously my GameStage class works in Flash too. Is there something about retrieving data from the SharedObject that I'm not aware of?
My prediction is that I will not be able to store my stage data this way. If that is the case, could anyone suggest an alternative method to saving the data?