SharedObject class
115
Assign an owner
A more sophisticated strategy is to define a single client as the owner of a
property in a shared object for a limited period of time. You might write server code to create
a “lock” object, where a client can request ownership of a slot. If the server reports that the
request was successful, the client knows that it will be the only client changing the data in the
shared object.
Notify the client
When the server rejects a client-requested change to a property of the
shared object, the
SharedObject.onSync
event handler notifies the client that the change
was rejected. Thus, an application can provide a user interface to let a user resolve the conflict.
This technique works best if data is changed infrequently, as in a shared address book. If a
synchronization conflict occurs, the user can decide whether to accept or reject the change.
Accept some changes and reject others
Some applications can accept changes on a “first
come, first served” basis. This works best when users can resolve conflicts by reapplying a
change if someone else’s change preceded theirs.
Local disk space considerations
You can choose to make remote shared objects persistent on the client, the server, or both.
(Local shared objects are always persistent on the client, up to available memory and disk
space.)
By default, Flash can save locally persistent remote shared objects up to 100K in size. When
you try to save a larger object, Flash Player displays the Local Storage dialog box, which lets
the user allow or deny local storage for the domain that is requesting access. (Make sure your
Stage size is at least 215 by 138 pixels; this is the minimum size Flash requires to display the
dialog box.)
If the user selects Allow, the object is saved and
SharedObject.onStatus
is invoked with a
code
property of
SharedObject.Flush.Success
. If the user selects Deny, the object is not
saved and
SharedObject.onStatus
is invoked with a
code
property of
SharedObject.Flush.Failed
.
The user can also specify permanent local storage settings for a particular domain by right-
clicking (Windows) or Control-clicking (Macintosh) while a SWF file is playing, and then
selecting Settings and clicking Advanced. From the Settings Manager list, the user selects
Local Storage Settings to open the Local Storage Settings panel.
You can’t use ActionScript to specify local storage settings for a user, but you can display the
Local Storage dialog box for the user by using
System.showSettings(1)
.