3 Replies Latest reply on Jan 16, 2008 4:19 AM by theklue

    SharedObject Headaches

    daemon3
      Okay, I'm trying to flush an object when a user clicks a button. It worked fine until I tried to flush the object (error message is below). This is the ActionScript code (inside initApp()):
      -------------------------------------
      var time:Date = new Date();
      sobject.data.theTime = time;

      That's basically where the error occurs. I define sobject as a global variable like this:
      private sobject:SharedObject = new SharedObject();

      Here's the runtime error I get when I click the button:
      -------------------------------------
      Error: Error #2130: Unable to flush SharedObject.
      at Error$throwError()
      at flash.net::SahredObject/flush()
      at main/::initApp()
      at main/__Button2_click()
        • 1. Re: SharedObject Headaches
          theklue
          I think you should listen for the flush method to finish correctly:

          try {
          var status:String = sobject.flush( );
          if(status == SharedObjectFlushStatus.PENDING)
          { sobject.addEventListener(NetStatusEvent.NET_STATUS,flushStatusHandler);
          }
          }
          catch (error:Error)
          {
          Alert.show("Error doing flush");
          }


          private function flushStatusHandler(event:NetStatusEvent):void
          { event.target.removeEventListener(NetStatusEvent.NET_STATUS, flushStatusHandler);

          if(event.info.code == "SharedObject.Flush.Failed")
          {
          Alert.show("You must allow local data storage.");
          }
          }


          Hope this helps.


          Alberto
          • 2. Re: SharedObject Headaches
            peterent Level 2
            What I'm not seeing is: SharedObject.getLocal() - you have new SharedObject() which isn't how you get a local shared object.
            • 3. Re: SharedObject Headaches
              theklue Level 1
              Ups, that's true. I was assuming that it was a permissions problem. Let's see if this solves his headaches...