SharedObject class
121
All attributes of a shared object’s
data
property are available to all clients connected to the
shared object, and all of them are saved if the object is persistent. Attributes are volatile; if one
client changes the value of an attribute, all clients now see the new value. The shared object
created above contains the following information:
userName: Ramona
adminPrivileges: true
itemNumbers: 101,346,483
To delete attributes for local shared objects, use code such as
delete
so.data.attributeName
; setting an attribute to
null
or
undefined
for a local shared object
does not delete the attribute.
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]
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();
};
NO
TE
Do not assign values directly to the
data
property of a shared object, as in
my_so.data = someValue
; Flash ignores these assignments.
Содержание FLASH MEDIA SERVER 2-CLIENT-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR FLASH MEDIA SERVER...
Страница 1: ...Client Side ActionScript Language Reference for Flash Media Server 2...
Страница 4: ...4 Contents...
Страница 148: ...148 Client Side ActionScript Language Reference...