MACROMEDIA FLASH MEDIA SERVER 2-SERVER MANAGEMENT ACTIONSCRIPT LANGUAGE Manuale Utente Pagina 95

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 155
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 94
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
92
Example
The following example calls the
SharedObject.send() method to invoke the doSomething() method on the client
and passes the string
"This is a test":
var so = SharedObject.get("foo", true);
so.send("doSomething", "This is a test");
The following example is the client-side ActionScript code that defines the doSomething() method:
nc = new NetConnection();
nc.connect("rtmp://www.adobe.com/someApp");
var so = SharedObject.getRemote("foo", nc.uri, true);
so.connect(nc);
so.doSomething = function(str) {
// Process the str object.
};
SharedObject.setProperty()
so.setProperty(name, value)
Updates the value of a property in a shared object.
The
name parameter on the server side is the same as an attribute of the data property on the client side. For example,
the following two lines of code are equivalent; the first line is Server-Side ActionScript and the second is client-side
ActionScript:
so.setProperty(nameVal, "foo");
clientSO.data[nameVal] = "foo";
A shared object property can be modified by a client between successive calls to SharedObject.getProperty()
and
SharedObject.setProperty(). If you want to preserve transactional integrity, call the
SharedObject.lock() method before modifying the shared object; be sure to call SharedObject.unlock() when
you finish making modifications. If you call
SharedObject.setProperty() without first calling
SharedObject.lock(), the change is made to the shared object, and all object subscribers are notified before
SharedObject.setProperty() returns. If you call SharedObject.lock() before you call
SharedObject.setProperty(), all changes are batched and sent when the SharedObject.unlock() method is
called. The
SharedObject.onSync() handler on the client side is invoked when the local copy of the shared object
is updated.
Note: If only one source (whether client or server) is updating a shared object in a server-side script, you don’t need to
use the
lock() or unlock() method or the onSync() handler.
Availability
Flash Communication Server 1
Parameters
name The name of the property in the shared object.
value An ActionScript object associated with the property, or null to delete the property.
Example
The following example uses the
SharedObject.setProperty() method to create the city property with the value
San Francisco. It then enumerates all the property values in a for loop and calls trace() to display the values.
myInfo = SharedObject.get("foo");
var addr = myInfo.getProperty("address");
Vedere la pagina 94
1 2 ... 90 91 92 93 94 95 96 97 98 99 100 ... 154 155

Commenti su questo manuale

Nessun commento