ProblemYou want two movies within the same domain to have access to the same LSO. SolutionSpecify a local path parameter when creating and opening the LSO. DiscussionBy 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 in movie.swf, which is served from http://www.person13.com/ascb, the LSO is stored at a location such as the following: C:\Documents and Settings\[user name]\Application Data\Macromedia\Flash Player\#SharedObjects\[random directory name]\person13.com\example.sol The difference in this directory versus the one presented earlier is that it lacks the movie and path information. An LSO created this way can be opened by any other Flash movie in the same domain with the following line of ActionScript: var example:SharedObject = SharedObject.getLocal( "example", "/" ); It is important to understand that a movie can only create and/or open an LSO within the same full or partial path. To understand this, consider an example with two Flash movies: movieOne.swf and movieTwo.swf. Both movies are served from the same domain (http:// www.person13.com) but at different paths. movieOne.swf is served from http:// www.person13.com/ascb/firstGroup, and movieTwo.swf is served from http:// www.person13.com/ascb/secondGroup. In this scenario, movieOne.swf can create and read LSOs with any of the following local path values: / /ascb /ascb/firstGroup and movieTwo.swf can create and read LSOs with any of the following local path values: / /ascb /ascb/secondGroup Therefore, if you want both movies to be able to access a common LSO, you must specify one of the two local paths that the movies share (/ or /ascb) when you invoke the getLocal( ) method. To illustrate how you can share data between two (or more) Flash movies within the same domain, take a look at the following example. If the movies don't exist within the same directory, you must first specify a common local path to both of them in the directory hierarchies. Start by looking at what happens if you fail to specify a common local path:
|