~~NOTOC~~ ====== SQLsave ====== ---- dataentry extension ---- author_url : http://www.lucaspaakh.com description : A simple way to save games using a SQL database in Air. lastupdate_dt : Sep 12, 2014 compatible : any depends : none tags : SQL, save, database, simple, easy, sharedobjects homepage_url : https://gist.github.com/Kajenx/b5561a848ca93ddc5dec download_url : https://gist.github.com/Kajenx/b5561a848ca93ddc5dec/download ---- ===== Overview ===== 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(); ===== Changelog ===== * //2014/09/12 16:41//: First public version ===== Source Code ===== %gist(b5561a848ca93ddc5dec)% ===== User Comments ===== //Feel free to edit this part of the page!//