
SharedObject 1085
To create
private
values for a shared object--values that are available only to the client instance
while the object is in use and are not stored with the object when it is closed--create properties
that are not named
data
to store them, as shown in the following example:
var my_so:SharedObject = SharedObject.getLocal("superfoo");
my_so.favoriteColor = "blue";
my_so.favoriteNightClub = "The Bluenote Tavern";
my_so.favoriteSong = "My World is Blue";
for (var prop in my_so) {
trace(prop+": "+my_so[prop]);
}
The shared object contains the following data:
favoriteSong: My World is Blue
favoriteNightClub: The Bluenote Tavern
favoriteColor: blue
data: [object Object]
Availability:
ActionScript 1.0; Flash Player 6
Example
The following example saves text from a TextInput component instance to a shared object
named
my_so
(for the complete example, see
SharedObject.getLocal()
):
// Create a listener object and function for the <enter> event.
var textListener:Object = new Object();
textListener.enter = function(eventObj:Object) {
my_so.data.myTextSaved = eventObj.target.text;
my_so.flush();
};
See also
flush (SharedObject.flush method)
public flush([minDiskSpace:Number]) : Object
Immediately writes a locally persistent shared object to a local file. If you don't use this
method, Flash writes the shared object to a file when the shared object session ends—that is,
when the SWF file is closed, that is when the shared object is garbage-collected because it no
longer has any references to it or you call
SharedObject.clear()
.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...