var my_so:SharedObject = SharedObject.getLocal("superfoo");
my_so.data.itemNumbers = items_array;
my_so.data.adminPrivileges = currentUserIsAdmin;
my_so.data.userName = currentUserName;
for (var prop in my_so.data) {
trace(prop+": "+my_so.data[prop]);
}
All attributes of a shared object's
object contains the following information:
userName: Ramona
adminPrivileges: true
itemNumbers: 101,346,483
Note: Do not assign values directly to the
so.data = someValue
To delete attributes for local shared objects, use code such as
setting an attribute to
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
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
(for the complete example, see
my_so
// create listener object and function for <enter> event
var textListener:Object = new Object();
textListener.enter = function(eventObj:Object) {
my_so.data.myTextSaved = eventObj.target.text;
my_so.flush();
};
property are saved if the object is persistent, and the shared
data
data
; Flash ignores these assignments.
or
null
undefined
to store them, as shown in the following example:
data
SharedObject.getLocal()
property of a shared object, as in
delete so.data.attributeName
for a local shared object does not delete the attribute.
):
SharedObject.data
;
401
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?