This is a simple class that works just like the SharedObjects in flash. Essentially, it just saves an object into an encrypted SQL database. It should work well for storing the information most games need to store, like the current level or a username.
Use this to initialize:
// NOTE: this isn't the most secure way to create an encryption key var tempByte:ByteArray = new ByteArray(); tempByte.writeUTFBytes("BLAHblahBLAHblah"); // use a 16 character string var MobileSave:SQLSave = new SQLSave("NAME_OF_FILE", tempByte); // The "data" object is automatically populated when SQLSave starts, // so you can immediately set your variables MyVariable = MobileSave.data.MyVariable; MyVariable2 = MobileSave.data.MyVariable2;
Then, use this to save data later:
MobileSave.data.MyVariable = MyVariable; MobileSave.data.MyVariable2 = MyVariable2; // Unlike SharedObjects, you MUST call the flush function to save // to the database every time! Don't call this too often. Maybe when // the player switches levels or hits a check point. MobileSave.flush();
%gist(b5561a848ca93ddc5dec)%
Feel free to edit this part of the page!