Search code examples
actionscript-3flashshared-objects

It's possible to write a sharedobject when allowscriptaccess is = "never"?


I will try to write a sharedObject item using my swf embeded into an html page. "allowscriptaccess" is setted to "never". I can't write sharedObject!

However if I set allowscriptaccess to "always", write action work well...

If I can't use sharedObject with allowscriptaccess setted to never, exist alternative for saving data?

I write a little and stupid example:

public class Main extends Sprite {
    private var SHARED_NAME:String = "__SO__";
    private var so:SharedObject;
    Security.allowDomain("*");
    Security.allowInsecureDomain("*");
    public function Main() {
        this.so = SharedObject.getLocal(this.SHARED_NAME, "/");
        this.setSharedObj("YEAHHHHHHHH");
        this.getSharedObj();
    }

    public function getSharedObj(clientId:String = null):Object {
        var url:String = "http://localhost:8080?so=" + this.so.data.test;
        var request:URLRequest = new URLRequest(url);
        var loader:URLLoader = new URLLoader();
        loader.load(request);
        return this.so.data;
    }

    public function setSharedObj(setValue:String):void {
        this.so.data.test = setValue;
        this.so.flush();
    }

}

When embed the compiled swf using AllowScriptAccess: "never", get Request never have setted the queryparam so. If set AllowScriptAccess to "always" queryparam will be correctly setted


Solution

  • @akmozo is right, the problem was not related by AllowScriptAccess, but from my way of testing.

    The problem is: Using firefox in anonymous mode, every time you reload the page, shared object are deleted. I thought for anonymous session are saved, it is not so!