Application Development Tips and Tricks > File types and paths > Shared object files

 

Shared object files

Any shared object, either local or remote, can exist dynamically (for the life of the application instance) or can be saved for use as persistent data. This section discusses the three types of persistent shared objects you can create: persistent local shared objects, remote shared objects that are persistent only on the server, and remote shared objects that are persistent on the client and the server. (For more information on shared objects in general, see Understanding shared objects.)

Local shared objects are always persistent on the client, up to available memory and disk space. However, by default Flash can save locally persistent remote shared objects only up to 100 K in size. When you try to save a larger object, the Flash Player displays a Local Storage dialog box, which lets the user allow or deny local storage for the domain that is requesting access. The user can also use this dialog box to delete all locally persistent remote shared objects. For more information, see "Local disk space considerations" in the SharedObject entry of the Client-Side Communication ActionScript Dictionary.

 
Persistent local shared objects

You create persistent local shared objects by using the client-side SharedObject.getLocal command. Persistent local shared objects have the extension .sol and are stored on the client machine in a directory associated with the user who created the shared object. On Windows, the default location is C:\Documents and Settings\userName\Application Data\Macromedia\Flash Player\serverSubdomain\pathToMovie\movieName.swf. (You can override the default by passing a value for the localPath parameter of the SharedObject.getLocal command.)

For example, if your logon ID is jsmith, you are running your server on a local machine (localhost), your movie is named myMovie.swf and is located in the C:\test directory, a local shared object created by the code below would be stored in the following location: C:\Documents and Settings\jsmith\Application Data\Macromedia\Flash Player\localhost\test\myMovie.swf.\myObject.sol.

my_so = SharedObject.getLocal("myObject");

 
Remotely persistent shared objects

You create remote shared objects that are persistent only on the server by passing a value of true for the persistence parameter in the client-side SharedObject.getRemote command or in the server-side SharedObject.get command. These shared objects are named with the extension .fso, and are stored on the server in a subdirectory of the application that created the shared object. The Flash Communication Server creates these directories automatically; you don't have to create a directory for each instance name. On Windows, the default location is C:\Program Files\Macromedia\Flash Communication Server MX\applications\appName\sharedobjects\instanceName.

For example, a remote shared object created by the code below would be stored in the following location: ..\applications\myWhiteboard\sharedobjects\monday\myObject.fso.

my_nc = new NetConnection();
my_nc.connect("rtmp://myFlashServer.myDomain.com/myWhiteboard/monday");

// The third parameter of "true" specifies that the object 
// should persist on the server.
my_so.getRemote("myObject", my_nc.uri, true);
my_so.connect(my_nc);

 
Remotely and locally persistent shared objects

You create remote shared objects that are persistent on the client and the server by passing a local path for the persistence parameter in your client-side SharedObject.getRemote command. The locally persistent shared object is named with the extension .sor and is stored on the client in the specified path. The remotely persistent .fso file is stored on the server in a subdirectory of the application that created the shared object (see Remotely persistent shared objects).

By specifying a partial path for the location of a locally persistent remote shared object, you can let several movies from the same domain access the same shared objects. For more information, see SharedObject.getRemote in the Client-Side Communication ActionScript Dictionary.