How to use SaveManager.as
In order to use the save manager, first you will have to create an instance of it. To create an instance, you will have to pass as parameter a name for the game. For example you can do the following:
saveManager = new SaveManager("AwesomeGame");
In this case we are calling the game “AwesomeGame”. Once it is created you will be able to save and load information.
If you want to save information you will have to create a dictionary with all the parameters you want to save. For example:
var data:Dictionary = new Dictionary(); data["CharacterName"] = "N00b"; data["Lvl"] = 100; data["Gold"] = -26; saveManager.save(data);
Here we are creating a dictionary with all the information we need and saving it using the save manager. The file will be named with the name we placed for the game.
Now, if we want to load this information we will have to call the function load and once it is loaded, we will be able to get the information:
First we call the method load, then we get acces to the information, for example, we will trace the character name we saved before:
In addition, when calling the function load we can listen the event Event.COMPLETE that will be dispatched once the load finishes.
- dataLoaded:Dictionary = new Dictionary();