16.5.1 ProblemYou want two movies within the same domain to have access to the same local shared object. 16.5.2 SolutionSpecify a local path parameter when creating and opening the local shared object. 16.5.3 DiscussionBy 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:
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", "/"); If the preceding code exists in myMovie.swf, which is served from www.person13.com/ascb/, the local shared object is stored at the following location:
An LSO created in this way can be opened by any other Flash movie in the same domain with the following line of ActionScript: my_l_so = SharedObject.getLocal("myFirstLSO", "/"); 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 www.person13.com but at different paths. movieOne.swf is served from www.person13.com/ascb/firstGroup/, and movieTwo.swf is served from 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, let's take a look at an example. If the movies don't exist within the same directory, we must specify a local path that is common to both of them in the directory hierarchy. Let's start by looking at what happens if we fail to specify a common local path:
16.5.4 See AlsoChapter 17 |