Loading data from Shared Object-Doh!

Hi guys,

I’m trying (and failing) to save and reload data from a shared object. I can create the object and save data to it so long as I keep the file open. My problem is accessing the data again when I re-open the program. I created the shared object using:

[COLOR=red]var DataStore:SharedObject = SharedObject.getLocal(“DataStore”);[/COLOR]

write an array to its data property using:
[COLOR=red]DataStore.data.PlayerStore=PlayerStore//saves my array[/COLOR]

and use [COLOR=red]DataStore.flush();[/COLOR] to save data persistently.

My problem comes in reloading the data. I guess I don’t want to do:
[COLOR=red]var DataStore:SharedObject = SharedObject.getLocal(“DataStore”);[/COLOR] again
because that would overwrite the original data ,so I check to see if DataStore still exists and holds data by making the creation of the shared object conditional upon its prior existence:

[COLOR=red]if(DataStore.data.PlayerStore==undefined) {[/COLOR]
[COLOR=red][/COLOR]
[COLOR=red]var DataStore:SharedObject = SharedObject.getLocal(“DataStore”);[/COLOR]
[COLOR=red]}[/COLOR]
[COLOR=red]else{[/COLOR]
[COLOR=red]PlayerStore=DataStore.data.PlayerStore;[/COLOR]
[COLOR=red]}[/COLOR]

This fails to load any data. Any ideas out there? I’ve checked out all the tutorials and they are a little vague on how to load data once you’ve closed the program down. This has stopped me in my tracks for a week and its doing my head in!