16.2. Adding Data to a Client-Side Shared Object
You want to add data to a client-side shared object (whether it be a remote or local shared object).
Add the values as properties of the shared object’s
Shared objects have a special built-in property named
data property is an
object to which you should add any information that you want to save
to the shared object:
// Store a
usernamevalue to the shared object. mySO.data.username = "Joey";
Properties attached directly to the shared object, rather than to its
data property, are not written to the shared
object. Thus, attaching properties directly to the shared object is
useful only for data that does not need to persist between sessions.
Therefore, the following code is potentially an erroneous attempt to
mySO.someVal = "this value is lost when the movie closes";
The correct approach is to attach the value to the
data property, as follows:
mySO.data.someVal = "this value is stored in the shared object";
You can store several native ActionScript datatypes to the shared
data property, as
mySO.data.myArray = new Array("a", "b", "c"); mySO.data.myDate = new Date( );
However, you cannot store movie clips, buttons, text fields, or
shared objects themselves to a shared object’s
data property such that the data persists
correctly between sessions.
You can also store objects created from custom classes to a shared
data property. However, for the object to be properly ...