The SharedObject class
Shared objects can be used for a wide number of purposes, and can be designed and used in a
number of ways. This section provides some items to consider as you begin using shared
objects in your applications.
About synchronizing shared objects
Before attempting to work with a remote shared object, you should first check that the
SharedObject.connect()
connection, and then wait until you receive a result from the function you have assigned to
the
SharedObject.onSync
locally—before
SharedObject.onSync
The
SharedObject.onSync
properties of the remote shared object are changed. The handler is also invoked the first time
a client uses the
SharedObject.getRemote()
that is persistent locally or on the server. In the latter case, all the object properties are set to
empty strings, and
SharedObject.onSync
to
. Then
"clear"
SharedObject.onSync
set to
, and the properties of the client's instance of the remote shared object will be
"change"
set to match those on the server.
If you are having problems understanding how your shared object is behaving, it helps to
place some debug code in your
my_so.onSync = function(list) {
for (var k in list) {
trace("name = " + list[k].name + ", event = " + list[k].code);
}
// do whatever else you want to do here
}
Using shared object slots effectively
The decision to encapsulate shared object data in a single slot (
or to spread it among multiple slots depends partially on how your application posts changes
to the object. For example, if your application needs to send an entire array of strings to all of
the connected clients at specific intervals, you can store the entire array in a single slot.
52
Using Media Classes
method returned a value of
handler. If you fail to do so, any changes you make to the object
is invoked—may be lost.
handler is invoked when any of the
method to connect to a remote shared object
is invoked with the value of the
is invoked again, this time with the value of
SharedObject.onSync
, indicating a successful
true
SharedObject.data
code
handler, as in the following example:
SharedObject.data
property set
code
property)
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?
Questions and answers