# Saving array values using SharedObject

**URL:** <https://forum.kirupa.com/t/saving-array-values-using-sharedobject/294054>\
**Category:** flash\
**Created:** [August 7, 2009, 4:29pm UTC](https://forum.kirupa.com/t/saving-array-values-using-sharedobject/294054 "2009-08-07T16:29:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BoppoBoy](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@BoppoBoy](https://forum.kirupa.com/u/BoppoBoy)\
**Post date:** [August 7, 2009, 4:29pm UTC](https://forum.kirupa.com/t/saving-array-values-using-sharedobject/294054/1 "2009-08-07T16:29:42Z")

</div>

I’m trying to write a save function for my project using a SharedObject. However, I’ve noticed that when you save Array values to one, the values only stay in there when loading the game from the same instance I saved it in. Here’s my code:

I’m saving an Array of a user-defined class “Job”:

```auto
public function saveGame(v_saveGameData:SharedObject):Boolean{
            v_saveGameData.data.jobHistory = Main_Game(parent).jobHistory as Array;
            ...
           }

```

Now I load the data:

```auto
public function loadGame(v_loadGameData:SharedObject):Boolean{
           Main_Game(parent).jobHistory = v_loadGameData.data.jobHistory as Array;
           trace("JobHistory: " + Main_Game(parent).jobHistory);
           ...
           }

```

If I save my game, go to the main menu, and load my game, the trace reads:  
“JobHistory: [object Job]”  
and the game properly loads.

However, if I close my game, reopen the file, then load, the trace reads:  
“JobHistory: [object Object]”  
and I get an error about “not being able to convert type Object to Job”

Seems to me, the problem is that when I close down the game, my save data forgets the custom class type stored in the array. Does anyone know how to fix this?
