Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Look at the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" rel="nofollow"><code>SharedObject</code></a> class; particularly its <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html#data" rel="nofollow"><code>data</code></a> property.</p> <p>Essentially:</p> <ol> <li><p>Define a <code>SharedObject</code> like so:</p> <p><code>var saveData:SharedObject = SharedObject.getLocal("MyGame");</code></p></li> <li><p>Use the <code>data</code> property to store information which will be accessible the next time you open the application. It's important to note that the data will only be retained if the <code>.swf</code> remains in the same location, either on the web or locally.</p> <p><code>if(!saveData.data.test)</code> <br /> &nbsp;&nbsp;&nbsp;&nbsp;<code>saveData.data.test = "Test string";</code></p></li> <li><p>You'll be able to access the information you've stored in the <code>data</code> object as expected:</p> <p><code>trace(saveData.data.test); // Test string</code></p></li> </ol> <p>The idea is that initially you'll create all of the properties that you may want to save when the game launches for the first time:</p> <pre><code>if(!saveData.data.ready) { saveData.data.ready = true; saveData.data.playerHealth = 100; saveData.data.levelsUnlocked = 1; } </code></pre> <p>And when you hit "save", overwrite these properties:</p> <pre><code>function save(so:SharedObject):void { so.data.playerHealth = player.health; so.data.levelsUnlocked = currentLevel; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload