Shared Object and dealing with its annoyances

4 posts

Flag Post

I know this isn’t the best spot to ask, but I need some help with the SharedObject in Flash 8. It automatically updates and saves (aka flushes) the variables saved to the [Shared Object instance].data section… Unfortunately, this isn’t exactly beneficial when you’re attempting to make a game that only saves when you want it to (and not all of the time).

I’ve been trying to look around forums to figure out how to prevent this, and to no avail. Do any coders here know how to manipulate the Shared Object well?

I’m also having a major issue with saving custom-made Class instances to it. Since Flash only duplicates the pointer and not the actual data, am I forced to store all of the instance’s data in a monstrous Array?

Flag Post

I usually create a custom class for this. When I request it to, the class gathers all necessary data from the game and writes it to the shared object at that time, and that time only.

Flag Post

One of my main issues aside from the class file issue (since I can work around it with a cloneInstance() type function) is when Flash automatically updates the .data portions of the Shared Object. For instance, say I have an inventory Array, and the first 5 portions are occupied with an InventoryItem instance. I hit save, and it saves my inventory array, which is fine. However, if I start adding items to my array and shut down the Flash, then it automatically adds those items to .data array that I stored… This isn’t very effective for any game where you don’t want a real-time update of all your variables.

I have no idea how to work around this, as I can’t seem to find many tutorials that explain how to utilize the SharedObject in any specific way except to remember Highscores… Arcane, I tried your method (which I already had in mind), but it doesn’t prevent the above situation from occurring.

Could I nullify the SharedObject variable (whatever I made it) after saving to prevent a real-time update?

Flag Post

Okay, sorry for a message spam. I think I figured out my issue with the automatic updating. If I set the SharedObject variable I created to “null”, then it doesn’t automatically update my file. I’ll just have to use a cloning function for my class files. Thanks for the help and the jump-start on how to solve this. :)