6

Simple question is, how do i detect in actionscript if user have blocked from writing data to shared object?

sharedObj = SharedObject.getLocal("rememberme");

This return always shared object but it's size is 0, even I have blocked shared object.

When I'm trying to save data to shared object and flush it, it throws me an error, because writing is blocked. So what would be the right way check if writing to shared object is disabled?

Error: Error #2130: Unable to flush SharedObject.

1 Answer 1

10
var my_so:SharedObject = SharedObject.getLocal("mySpace");
var flushStatus:String = null;
try {
    flushStatus = my_so.flush();
} catch (error:Error) {
    trace("Error...Could not write SharedObject to disk\n");
}
if (flushStatus != null) {
    switch (flushStatus) {
        case SharedObjectFlushStatus.PENDING :
            trace("Requesting permission to save object...\n");
            my_so.addEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
            break;
        case SharedObjectFlushStatus.FLUSHED :
            trace("Value flushed to disk.\n");
            break;
    }
}
function onFlushStatus(event:NetStatusEvent):void {
    trace("User closed permission dialog...\n");
    switch (event.info.code) {
        case "SharedObject.Flush.Success" :
            trace("User granted permission -- value saved.\n");
            break;
        case "SharedObject.Flush.Failed" :
            trace("User denied permission -- value not saved.\n");
            break;
    }
my_so.removeEventListener(NetStatusEvent.NET_STATUS, onFlushStatus);
}

If shared object is blocked u can catch the error report else if 0 it goes to SharedObjectFlushStatus.PENDING.

SOURCE

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.