3 Replies Latest reply on Feb 3, 2011 2:53 AM by Mogge 3000

    SharedObject not working

    Mogge 3000 Level 1

      Hi,

       

      I'm struggling to get a LSO (local shared objects) within a Flash Builder, Flex project on Windows 7 to store a teststring so that I can access it when I reopen the app. I'm using this basic code to test:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/mx" 
                        creationComplete="testLSO()">
      
      <fx:Script>
           <![CDATA[     
                import flash.net.SharedObject;
      
                public function testLSO():void 
                {
                     var so:SharedObject = SharedObject.getLocal("myTestLSO","/");
                     
                     if(so.data.teststring != null)
                     {
                          testText.text = so.data.teststring;
                     } else {
                          so.data.teststring = "it worked";
                          testText.text = "it didnt work, try again.";
                     }
                }
           ]]>
      </fx:Script>
           <s:Label id="testText" x="100" y="100"/>
      </s:Application>
      

       

      When I run this in a Flash CS5 project (almost identical code) it works like a charm. From Flash Builder Burrito however, it never stores the teststring so that I can access it after reopening the app. I can access the teststring once it's been set as long as the app is still open.

       

      • I don't get any errors at all.
      • I've tried to use so.flush() without any difference.
      • I've tried using different Flex SDK's including 4.1 and Hero.
      • I'm using Flash Player 10,1,102,64 but also testid it with Adobe Flash Player 10.2 rc.

       

      This is really driving me nuts, so please help me in any way you can.

       

      Regards

       

      //Morgan

        • 1. Re: SharedObject not working
          _spoboyle Level 4

          I know you said you've used flush but have you tried looking at the flush status?

           

          take a look at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject. html#includeExamplesSummary

           

          are you getting a success or failed event?

          • 2. Re: SharedObject not working
            Mogge 3000 Level 1

            Hi,

             

            Yes, I actually ran the entire example found in the docs with the same result, nothing is saved. The flushstatus is "Flushed to disk" so it seams to work so far but then something must happen because it doesnt work...

             

            //Morgan

            • 3. Re: SharedObject not working
              Mogge 3000 Level 1

              Ahaaa!

               

              I narrowed it down to a browser setting. I mostly use FireFox but decided to try out the new Flash Player 10.2 rc for IE and the LSO just started working. This had me investigation the FireFox settings on the machine I was working on. It turns out FireFox had the "Automatically start Firefox in a private browsing session" turned on. Turning this feature off made the LSO work as expected.

               

              Ok, thats great news, problem solved, right? Well what about other users of the app with the same setting turned on... Is there a way to check for this setting? I've looked at the docs but found nothing that checks for this. I guess I could use the ExternalInterface and something like below outside of the Flash Player:

               

               

              var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
              getService(Components.interfaces.nsIPrivateBrowsingService);
              return inPrivateBrowsingMode = pbs.privateBrowsingEnabled;
              

               

              I could then prompt the user to change the setting if he/she want the functionality of LSO's. Anyone already implemented this? Any other ideas?

               

              Thanks for your help!

               

              //Morgan