O'Reilly logo

ActionScript 3.0 Cookbook by Joey Lott, Darron Schall, Keith Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharing Data Between Flash Applications

Problem

You want two movies within the same domain to have access to the same LSO.

Solution

Specify a local path parameter when creating and opening the LSO.

Discussion

By default, LSOs are saved to a path on the client computer that is unique to the domain, path, and name of the .swf file calling the getLocal() method. This prevents name conflicts between LSOs from different domains, or even different movies on the same domain. For example, on a system running Windows XP, if a movie named movie.swf served from http://www.person13.com/ascb writes an LSO named example, the data is saved in a location such as the following:

C:\\Documents and Settings\\[user name]\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\[random directory name]\\person13.com\\ascb\\movie.swf\\example.sol

The name of the .swf file is included in the path to which the LSO is saved so it won’t conflict with an LSO named example created by another movie served from the same domain and path. However, in some cases, you want two movies on the same domain to have access to the same LSO. In these cases, you should use the optional local path parameter when creating and opening the LSO using getLocal().

The local path parameter (the second parameter passed to getLocal()) must be a string that specifies the full or partial path to the .swf file that created the LSO; for example:

var example:SharedObject = SharedObject.getLocal( "example", "/" );

If the preceding code exists ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required