开发者

Flex: How to detect if user has blocked shared object from writing

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, becau开发者_开发问答se 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜