SharedObject class

Availability

Flash Communication Server MX 1.0.

The SharedObject class lets you store data on the server and share data between multiple client applications in real time. Shared objects can be temporary, or they can persist on the server after an application has closed; you can consider shared objects as real-time data transfer devices.

NOTE

 

This entry explains the server-side SharedObject class. You can also create shared objects with the client-side SharedObject class. For more information, see "SharedObject class" in Client-Side ActionScript Language Reference for Flash Media Server 2.

The following list describes common ways to use shared objects in server-side ActionScript:

It is important to understand the following information about using shared objects in server-side ActionScript:

If you write a server-side script that modifies multiple properties, you can prevent other clients from modifying the object during the update by calling the SharedObject.lock() method before updating the object. Then you can call SharedObject.unlock() to commit the changes and allow other changes to be made. Call SharedObject.mark() to deliver change events in groups within the lock() and unlock() methods.

When you get a reference to a proxied shared object, any changes made to the object are sent to the instance that owns the object. The success or failure of any changes are sent using the SharedObject.onSync event handler, if it is defined.

The SharedObject.lock() and SharedObject.unlock() methods cannot lock or unlock proxied shared objects.

NOTE

 

For more information on shared objects, see "About streams and shared objects", "Shared object flow", and "Shared object files" in Developing Media Applications.

Method summary for the SharedObject class

Method

Description

SharedObject.clear()

Deletes all the properties of a persistent shared object.

SharedObject.close()

Unsubscribes from a shared object.

SharedObject.commit()

Static; stores either a specific persistent shared object instance or all persistent shared object instances that are marked dirty.

SharedObject.flush()

Saves the current state of a persistent shared object.

SharedObject.get()

Static; creates a shared object or returns a reference to an existing shared object.

SharedObject.getProperty()

Gets the value of a shared object property.

SharedObject.getPropertyNames()

Returns an array of all the current valid properties in the shared object.

SharedObject.lock()

Locks the shared object instance. Prevents any changes to this object by clients until the SharedObject.unlock() method is called.

SharedObject.mark()

Delivers all change events to a subscribing client as a single message.

SharedObject.purge()

Causes the server to remove all deleted properties that are older than the specified version.

SharedObject.send()

Sends a message to the client subscribing to this shared object.

SharedObject.setProperty()

Sets a new value for a shared object property.

SharedObject.size()

Returns the number of valid properties in a shared object.

SharedObject.unlock()

Unlocks a shared object instance that was locked with SharedObject.lock().

Property summary for the SharedObject class

Property

Description

SharedObject.autoCommit

A Boolean value indicating whether the server periodically commits all persistent shared objects to be stored (true) or not (false).

SharedObject.isDirty

A Boolean value indicating whether the persistent SharedObject has been modified since the last time it was stored (true) or not (false).

SharedObject.name

The name of a shared object.

SharedObject.resyncDepth

The depth that indicates when the deleted values of a shared object should be permanently deleted.

SharedObject.version

The current version number of a shared object.

Event summary for the SharedObject class

Event

Description

SharedObject.handlerName

A placeholder for an event handler; the handler is invoked when a shared object receives a broadcast message with the same name.

SharedObject.onStatus

Reports errors, warnings, and status messages for a shared object.

SharedObject.onSync

Invoked when a shared object changes.


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000747.html