Flash.net.SharedObject

Asked by jakebob

i compile my flash project and i get "Class not found : flash.net.SharedObject". Is this class not implement? is there an alt way/workaround for this?

Question information

Language:
English Edit question
Status:
Answered
For:
jeash Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Niel Drummond (niel-drummond) said :
#1

No, flash.net.SharedObject is not yet implemented (feel free to provide a patch) - it's possible that the client-side features of SharedObject will be implemented at some future point.

The alternative is to use standard browser cookies:

js.Cookie.set("bla", "fasel");
js.Cookie.get("bla");

see this for reference: http://haxe.org/api/js/cookie

Revision history for this message
Nick Glushchenko (nickalie) said :
#2

My implementation of SharedObject uses Local Storage. For me it's better than cookies beacase Local Storage have more space and not sended on server with each request. But this implementation depends on hxjson2 library.

import js.Storage;
import hxjson2.JSON;

class SharedObject
{
 private static var _storage:Storage;

 public var data:Dynamic;
 private var _name:String;

 private function new(name:String)
 {
  _name = name;

  var str:String = _storage.getItem(_name);

  if (str != null && str != "")
  {
   data = JSON.decode(str);
  }
  else
  {
   data = { };
  }
 }

 public function clear():Void
 {
  _storage.removeItem(_name);
  data = { };
 }

 public function flush(minDiskSpace:Int = 0):Void
 {
  var str:String = JSON.encode(data);
  _storage.setItem(_name, str);
 }

 public static function getLocal(name:String):SharedObject
 {
  if (_storage == null)
  {
   _storage = Storage.getLocal();
  }

  return new SharedObject(name);
 }
}

Revision history for this message
Niel Drummond (niel-drummond) said :
#3

SharedObject has already been implemented in the tip of the repository, using the native haxe Serializer.

I would be happy if you could test it to make sure it works with your code before the next release.

thanks,

- Niel

Can you help with this problem?

Provide an answer of your own, or ask jakebob for more information if necessary.

To post a message you must log in.