Detailed instructions for use are in the User's Guide.
[. . . ] Server-Side ActionScript Language Reference
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally. [. . . ] A Boolean value indicating whether the persistent SharedObject has been modified since the last time it was stored (true) or not (false). The depth that indicates when the deleted values of a shared object should be permanently deleted. The current version number of a shared object.
SharedObject. isDirty
SharedObject. name SharedObject. resyncDepth
SharedObject. version
Event summary for the SharedObject class
Event
SharedObject. handlerName
Description
A placeholder for an event handler; the handler is invoked when a shared object receives a broadcast message with the same name. Reports errors, warnings, and status messages for a shared object. Invoked when a shared object changes.
SharedObject. onStatus
SharedObject. onSync
SharedObject. autoCommit
Availability
Flash Media Server 2.
Usage
mySO. autoCommit
Description
Property; a Boolean value indicating whether the server periodically stores all persistent shared objects (true) or not (false). If autoCommit is false, the application must call SharedObject. commit() to save the shared object; otherwise, the data is lost.
SharedObject class
119
This property is true by default. This can be overridden by specifying the initial state using the following configuration key in the Application. xml file, as shown in the following example:
<SharedObjManager> <AutoCommit>false</AutoCommit> </SharedObjManager>
SharedObject. clear()
Availability
Flash Communication Server MX 1. 0.
Usage
mySO. clear()
Parameters
None.
Returns
Returns true if successful; false otherwise.
Description
Method; deletes all the properties of a single shared object and sends a clear event to all clients that subscribe to a persistent shared object. The persistent data object is also removed from a persistent shared object.
Example
The following example calls the clear() method on the shared object myShared:
var myShared = SharedObject. get("foo", true); var len = myShared. clear();
See also
Application. clearSharedObjects()
SharedObject. close()
Availability
Flash Communication Server MX 1. 0.
Usage
mySO. close()
120
Server-Side ActionScript Language Reference
Parameters
None.
Returns
Nothing.
Description
Method; detaches a reference from a shared object. A call to the SharedObject. get() method returns a reference to a shared object instance. The reference is valid until the variable that holds the reference is no longer in use and the script is garbage-collected. To destroy a reference immediately, you can call SharedObject. close(). You can use SharedObject. close() when you don't want to proxy a shared object any longer.
Example
In the following example, mySO is attached as a reference to shared object foo. When you call mySO. close you detach the reference mySO from the shared object foo.
mySO = SharedObject. get("foo"); // Insert code here. mySO. close();
See also
SharedObject. get()
SharedObject. commit()
Availability
Flash Media Server 2.
Usage
SharedObject. commit([name])
Parameters
name
A string indicating the name of the persistent shared object instance to store. If no name is specified or an empty string is passed, all persistent shared objects are stored. This parameter is optional.
Returns
A Boolean value indicating success (true) or failure (false).
SharedObject class
121
Description
Method (static); stores either a specific persistent shared object instance or all persistent shared object instances with an isDirty property whose value is true. Use this method if the SharedObject. autoCommit property is false and you need to manage when a shared object is stored locally.
Example
The following code commits all dirty shared objects to local storage when the application stops:
application. onAppStop = function (info){ // Insert code here. SharedObject. commit(); }
SharedObject. flush()
Availability
Flash Communication Server MX 1. 0.
Usage
mySO. flush()
Parameters
None.
Returns
A Boolean value of true if successful, false otherwise.
Description
Method; saves the current state of a persistent shared object.
Example
The following example places a reference to the shared object foo in the variable myShared. It then locks the shared object instance so that no one can make any changes to it, and then saves the shared object by calling myShared. flush(). After the shared object is saved, it is unlocked so that further changes can be made.
var myShared = SharedObject. get("foo", true); myShared. lock(); // Insert code here that operates on the shared object. myShared. flush(); myShared. unlock();
122
Server-Side ActionScript Language Reference
SharedObject. get()
Availability
Flash Communication Server MX 1. 0.
Usage
SharedObject. get(name, persistence [, netConnection])
Parameters
name
Name of the shared object instance to return.
persistence
A Boolean value: true for a persistent shared object; false for a nonpersistent shared object. If no value is specified, the default value is false.
A NetConnection object that represents a connection to an application instance. [. . . ] linebuf: source code of the offending line. Warning The ActionScript engine is low on runtime memory. This provides an opportunity for the application instance to free some resources or take suitable action. If the application instance runs out of memory, it is unloaded and all users are disconnected. [. . . ]