I have a game and I used Flash cs5 ActionScript3. I want to create a save button for the game. When the player loads the game, the saved game will open. Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Look at the
SharedObjectclass; particularly itsdataproperty.Essentially:
Define a
SharedObjectlike so:var saveData:SharedObject = SharedObject.getLocal("MyGame");Use the
dataproperty 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.swfremains in the same location, either on the web or locally.if(!saveData.data.test)saveData.data.test = "Test string";You’ll be able to access the information you’ve stored in the
dataobject as expected:trace(saveData.data.test); // Test stringThe 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:
And when you hit “save”, overwrite these properties: