18.06.2008, 11:30
|
|
Регистрация: Jun 2008
Адрес: Russia
Сообщений: 5
|
Skriv
Спасибо!
Как раз нашёл книгу "ActionScript 3.0 Game Programming University 2007" и в ней вот такой текст:
Цитата:
Saving Local Data
A common need in game development is to store bits of local data. For instance, you
could store the player’s previous score. Or, you could store some game options.
To store a piece of data on the user’s machine, we’ll use a local SharedObject.
Accessing a SharedObject is the same act as creating one. Just asking whether it exists
will create it.
To do this, just assign a variable to the SharedObject of a certain name, with the
getLocal function:
Код:
var myLocalData:SharedObject = SharedObject.getLocal(“mygamedata”);
The myLocalData object is able to take any number of properties of any type: numbers, strings, arrays, other objects, and so on.
If you had stored same data in a property of the shared object named gameinfo you
could access it with: myLocalData.data.gameinfo:
Код:
trace(“Found Data: “+myLocalData.data.gameinfo);
So, set this gameinfo property. Just set it as you would a regular variable:
Код:
myLocalData.data.gameinfo = “Store this.”;
Try running the test movie SavingLocalData.fla. It uses the trace function to output
the myLocalData.data.gameinfo property. Because that isn’t set to anything, you’ll get
undefined as the result. But then, it sets the value. So, the second time you run the test, you get “Store this.”
|
=)
__________________
no carrier
|