# Maintinain Object type persistance in SharedObject

**URL:** <https://forum.kirupa.com/t/maintinain-object-type-persistance-in-sharedobject/294948>\
**Category:** flash\
**Created:** [August 22, 2009, 10:06pm UTC](https://forum.kirupa.com/t/maintinain-object-type-persistance-in-sharedobject/294948 "2009-08-22T22:06:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keslen](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Keslen](https://forum.kirupa.com/u/Keslen)\
**Post date:** [August 22, 2009, 10:06pm UTC](https://forum.kirupa.com/t/maintinain-object-type-persistance-in-sharedobject/294948/1 "2009-08-22T22:06:53Z")

</div>

G’day folks, I’ve got this little problem that’s been confusing me for the past little while. I wrote a little script designed to save and load data using the SharedObject class. This is the meat of what I came up with.

```auto

public function saveGame(fileName:String, saveData:Object):void
{
	var saveFile:SharedObject = SharedObject.getLocal(fileName);
	saveFile.data.gameData = saveData;
}
		
public function loadGame(fileName:String):Object
{
	var saveFile:SharedObject = SharedObject.getLocal(fileName);
	return saveFile.data.gameData;
}

```

Now, this little script works perfectly when I’m dealing with ints, Strings and the like. However, a problem arises when I try to save a custom made Object dedicated to holding data for another class structure. It goes through the saving process just fine, but when I try to load it it gets locked into Object. I can’t access any functions and all (gameData is DataType) comparisons evaluate to false (even when testing against the dataType I saved it as).

So, I ask hopefully, is there something I’m missing? I’d be very grateful for any assistance that might lead to not having to encode all my data in the future.
