To code I used looks like this:
try { so = SharedObject.getLocal("/", "BTD2/002"); } catch(error:Error) { trace ("unable to access shared object " + strSOName + ", error " + error.name + ", saving disabled"); bFile = bOK = false; }
The key is the parameter "BTD2/002". This specifies both the path, "BTD2", and the filename "002", separated by a slash. If the path is unique (i.e. if you choose something non-obvious) only files for your game will be in that folder, so you can use whatever file names you like. I tend to use numeric ones so I can increment the number if I break and need to recreate the file format.
As the save location is independent of the game name and path to it this also opens up another possibility: more than one game could access the same file. One use might be for a game sequel to use settings from a previous game, such as a custom character or game progress.
The rest of the code is a try/catch block, about the only one in Bug Tunnel Defense, so I could set a flag to disable saving if the call failed. This might happen if the game was played on a machine where the user has no access to the file system, or if the disk were full.
No comments:
Post a Comment