0 Replies Latest reply on Jul 21, 2008 3:41 AM by mammut02

    EncryptedLocalStore works fine in IDE debug mode, but very slow after application installation

    mammut02
      Hello
      I'm trying to initialize a value in the ELS when the application start. It works fine in the Flash IDE, but when I package the application and install it, it takes a lot of time to initialize this value. Has anyone experienced this ?
      First the application try to read a value in the ELS, if it doesn't find this value, it generated a random number and store it in the ELS.
      Here is a piece of my code:

      public static function getID():String
      {
      var id:String = readELSValue("myKey");
      if (id == "")
      {
      id = String(Math.round((Rnd.random() * 88) + 10));
      writeELSValue("myKey", id);
      }
      return id;
      }

      public static function readELSValue(key:String):String
      {
      var storedValue:ByteArray = new ByteArray();
      var returnedValue:String = "";
      try
      {
      storedValue = EncryptedLocalStore.getItem(key);
      if(storedValue != null)
      {
      returnedValue = storedValue.readUTFBytes(storedValue.length);
      }
      }
      catch (e:Error)
      {
      trace(e.message);
      }
      return returnedValue;
      }


      public static function writeELSValue(key:String, value:String):void
      {
      var bytes:ByteArray = new ByteArray();
      try
      {
      bytes.writeUTFBytes(value);
      EncryptedLocalStore.setItem(key, bytes);
      }
      catch (e:Error)
      {
      trace(e.message);
      }
      }