MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Specifikace Strana 273

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 369
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 272
82
The following examples show a few ways shared objects are called within ActionScript programs.
Note that in order to create a remote shared object, you must first connect to the Flash
Communication Server with the RTMP protocol.
// Create a local shared object
so = SharedObject.getLocal("foo");
// Create a remote shared object that is not persistent on the server
nc = new NetConnection();
nc.connect("rtmp://server.domain.com/chat/room3";
so = SharedObject.getRemote("users", nc.uri);
so.connect(nc);
// Create a remote shared object that is persistent on the server
// but not on the client
nc = new NetConnection();
nc.connect("rtmp://server.domain.com/chat/room3";
so = SharedObject.getRemote("users", nc.uri, true);
so.connect(nc);
// Create a remote shared object that is persistent on the server
// and on the client
nc = new NetConnection();
nc.connect("rtmp://server.domain.com/chat/room3";
so = SharedObject.getRemote("users", nc.uri, "/chat");
so.connect(nc);
Designing remote shared objects
When designing remote shared objects, develop a model for how the data will be managed. Take
into account issues of data design and management, conflict resolution, and storage (persistence)
requirements, both locally and on the server. These issues are discussed briefly in this section.
When using a locally persistent remote shared object, make sure your Stage size is at least
215 by 138 pixels. The Flash Player needs at least this much space to display the Settings panels.
Data design and management
Data associated with shared objects is stored in attributes of the object’s
data properties; each set
of attributes constitutes one slot. For example, the following lines assign values to three slots of a
shared object:
so.data.userID = "myLogonName";
so.data.currentStatus = "in a meeting";
so.data.lastLogon = "February 27, 2002";
Each time a client changes an attribute, all the attributes for that slot are sent to the server and
then propagated to all clients attached to the object. Thus, the more information a slot contains,
the more network traffic is generated when any attribute in that slot is changed.
For example, consider a shared object with the following attributes occupying a single slot:
so.data.year.month.dayOfMonth = someValue;
If a client changes the value of the year, month, or dayOfMonth attribute, the entire slot is
updated, even though only one data item was changed.
Zobrazit stránku 272
1 2 ... 268 269 270 271 272 273 274 275 276 277 278 ... 368 369

Komentáře k této Příručce

Žádné komentáře