SharedObject.data
401
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
data
property are saved if the object is persistent, and the shared
object contains the following information:
userName: Ramona
adminPrivileges: true
itemNumbers: 101,346,483
Note:
Do not assign values directly to the
data
property of a shared object, as in
so.data = someValue
; Flash ignores these assignments.
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 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();
};
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...