3 Replies Latest reply: Nov 13, 2009 7:27 AM by Rothrock RSS

    SharedObject issue - help, please!

    Ziggizag Community Member

      Hello,

       

      I have a website where under a single domain (and in a single folder on a web server) - two flash movies are stored:

       

      MOVIE1.SWF and MOVIE2.SWF

       

      Is it possible to access local SharedObject set by MOVIE1 by MOVIE2 ???

       

      What I do:

       

      MOVIE1:

       

      var so:ShareObject = SharedObject.getLocal("myso");

      so.data.custname = "John";

      so.flush();

      trace(so.data.custname);

       

      -- John

       

      MOVIE2:

       

      var so:ShareObject = SharedObject.getLocal("myso");

      trace(so.data.custname);

       

      -- undefined

       

      As you may see - it is like local SharedObject was not shared actully but was "owned" by a movie where it was created.

       

      Any ideas how to fix it?

       

      Thanks ahead for your kind answers!

       

      Rgs,

      Ziggi

        • 1. Re: SharedObject issue - help, please!
          Rothrock Community Member

          Yup. By default a SO is "owned" by the file that created it. If you check the documentation for getLocal() you will see that you can give it a path argument that will expand which swfs (on your own domain) can access the SO.

          • 2. Re: SharedObject issue - help, please!
            Ziggizag Community Member

            Thank you very much for this prompt answer. Actually - documentation Adobe provided on the subject is less than informative. But indeed, the optional "path" parameter does the job.

             

            Rgs,

            Ziggi

            • 3. Re: SharedObject issue - help, please!
              Rothrock Community Member

              Glad you worked it out. I had only remembered what I read in the AS2 documentation, but I just checked out the AS3 documentation and it seems prety clear to me (I added the emphasis):

               

              Although the localPath parameter is optional, you should give some thought to its use, especially if other SWF files need to access the shared object. If the data in the shared object is specific to one SWF file that will not be moved to another location, then use of the default value makes sense. If other SWF files need access to the shared object, or if the SWF file that creates the shared object will later be moved, then the value of this parameter affects how accessible the shared object will be. For example, if you create a shared object with localPath set to the default value of the full path to the SWF file, no other SWF file can access that shared object. If you later move the original SWF file to another location, not even that SWF file can access the data already stored in the shared object.

               

              To avoid inadvertently restricting access to a shared object, use the localpath parameter. The most permissive approach is to set localPath to / (slash), which makes the shared object available to all SWF files in the domain, but increases the likelihood of name conflicts with other shared objects in the domain. A more restrictive approach is to append localPath with folder names that are in the full path to the SWF file. For example, for a portfolio shared object created by the SWF file at www.myCompany.com/apps/stockwatcher.swf, you could set the localPath parameter to /, /apps, or /apps/stockwatcher.swf. You must determine which approach provides optimal flexibility for your application.

              The trick is it is up near the top, not in the part where it describes the optional path parameter!