[SOLVED] My flashgame on FGL loses its savedata. Need help creating robust saving system


(Quang Tran) #1

I have my game on FGL right now and am preparing for sponsorship bidding. I noticed that every time I update the game, the save data on FGL gets wiped. Is this behavior exclusive to FGL or is that something I can expect to happen on websites as well? How can I make the saving robust so that if I update the game, user data doesn’t get wiped?

I’m using cookies and SharedObjects, and while I’ve been developing the game, the save data seems to be fine. It’s only online that I notice a problem.

Finally concerning flash game saving and cookies/sharedobjects, are there any best practices you guys recommend? Any pitfalls I should be aware of?

Appreciate any and all advice. Thanks!


(Bora Kasap) #2

I’m using FP’s Data class to save my data and it’s not mattering version of the game. It’s succesfully keeping save data even i update the game. But, it’s losing data only when i move the swf file to another folder, but i think it works different on websites, so, it must be about FGL, because i’m using the same thing on Kongregate, and there is not data loss when i update the game on Kongregate. But that doesn’t make sense to me, i can’t understand how can FGL reach your source, try to don’t change filename when updating your game? That may be about foldering the game save in computer into a file named with name of the gamefile(not sure about that), so, it loses data when you change folders, but that’s just an idea.


(Zachary Lewis) #3

I just read The Trick to Using SharedObject, and I have an idea of what could be causing it.

You’ll want to specify a path and a local root when you call SharedObject.localData().

If you don’t use a local path or name the save will be stored based on where the game is served from on the server. For example, if you’re uploading to a game site, fakesite.com, and they store the games at uploads/username/gamename/version, and your SavedObject call was

// Create a game save.
var savedGame:SharedObject = SharedObject.getLocal("save");
#SharedObjects/<random code>/fakesite.com/uploads/quasar/game-title/1/#save.sol

If you updated your game, your saved object would be stored at

#SharedObjects/<random code>/fakesite.com/uploads/quasar/game-title/2/#save.sol

Since these are different paths, the .swf will not be able to find it!

Furthermore, if you don’t set a custom name but you do use a local path,

// Create a game save.
var savedGame:SharedObject = SharedObject.getLocal("save", "\");

all of your saved data would be stored at

#SharedObjects/<random code>/fakesite.com/#save.sol

Since save is such a common name for game saves, there could very likely be multiple games with poorly-written saving that use the same file, causing potential corruption of data.

tl;dr

You’ll want to specify a path and a local root when you call SharedObject.localData().

// Create a game save.
var savedGame:SharedObject = SharedObject.getLocal("quasar/game-title/save", "/");

// Create game settings (for muting, input, et cetera).
var savedSettings:SharedObject = SharedObject.getLocal("quasar/game-title/settings", "/");

The first path, quasar/game-title/save plus the local path, /, will specify the location the data is stored on your user’s computer. If you uploaded this game, the saved directory would be found at

#SharedObjects/<random code>/fakesite.com/#quasar/game-title/save.sol

This is both unique (to prevent data corruption) and static (to ensure the file is always where you want it).


SharedObject flush problems. How to ensure saving succeeded?
Moving an swf, Data, SharedObject, and SharedObject.localPath
(Ultima2876) #4

FGL purposely mangles the swf filename and identifiers to force your save data to clear on their site. If you’re using the FlashPunk Data class you don’t need to worry about this happening on other sites - FGL does it specifically so you don’t get bugs with games retaining old data onsite and so that sponsors always get a ‘fresh’ look at the game.

Source: I have worked with FGL very closely for the last 2 years.


(Quang Tran) #5

Thanks for all the helpful replies guys!

I tried Zach’s solution and specified a local path (previously I just left that value empty). I then updated and it seems to be working!

I’m not showing the game to sponsors yet, so maybe FGL does mangle the filename and identifiers later.

Since we’re on the topic of saving, is there a possibility that the player’s computer settings doesn’t allow a flash game to save? I would like to detect that and inform the player before they start if possible.


(Zachary Lewis) #6

You should read that article I linked.


(Quang Tran) #7

Lol. Sorry. It was a long post. I must have skimmed it.


Shared object issue!
(Ultima2876) #8

Zach’s solution will work because it’s saving to a specific file each time. FGL’s mangling process only disrupts saves if they are using folder-based saving (one folder per swf cookie). However, make sure that if you update your game post-‘ready for bidding’ you’re not introducing savegame-related bugs that will put potential bidders off - if a sponsor is considering putting down a few thousand on your game then loads the game up to have another go and their old save messes something up that leads to bugs, it might deter them (which is FGL’s logic in attempting to force clearing of save data with every update).


(Quang Tran) #9

I will keep that in mind. Thanks!