O'Reilly logo

Actionscript Cookbook by Joey Lott

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

16.5. Sharing Information Between Movies Within the Same Domain

Problem

You want two movies within the same domain to have access to the same local shared object.

Solution

Specify a local path parameter when creating and opening the local shared object.

Discussion

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

D:\Documents and Settings\[UserName]\Application Data\Macromedia\Flash Player\person13.com\ascb\myMovie.swf\myFirstLSO.sol

The name of the .swf file is included in the path to which the LSO is saved so that it will not conflict with an LSO named myFirstLSO 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:

my_l_so = SharedObject.getLocal("myFirstLSO", ...

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