软硬度:如何检测,从写作,如果用户已阻止共享对象 [英] Flex: How to detect if user has blocked shared object from writing

查看:184
本文介绍了软硬度:如何检测,从写作,如果用户已阻止共享对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题是,我如何检测动作,如果用户已经从数据写入共享对象受阻?

  sharedObj = SharedObject.getLocal的(了rememberMe);
 

这回始终共享对象,但它的大小为0,即使我已封锁共享对象。

当我试图将数据保存到共享对象和冲洗,它引发了我的错误,因为写作被阻止。那么,什么是正确的方式检查是否写入共享对象是残疾人?

 错误:错误#2130:无法刷新共享对象。
 

解决方案

  VAR my_so:共享对象= SharedObject.getLocal的(MySpace的);
VAR flushStatus:字符串= NULL;
尝试 {
    flushStatus = my_so.flush();
}赶上(错误:错误){
    跟踪(错误...无法写入共享对象到磁盘的\ n);
}
如果(flushStatus!= NULL){
    开关(flushStatus){
        案例SharedObjectFlushStatus.PENDING:
            跟踪(请求允许保存对象... \ N);
            my_so.addEventListener(NetStatusEvent.NET_STATUS,调用onFlushStatus);
            打破;
        案例SharedObjectFlushStatus.FLUSHED:
            跟踪(刷新值到磁盘\ñ。);
            打破;
    }
}
函数调用onFlushStatus(事件:将NetStatusEvent):无效{
    跟踪(用户关闭权限对话框... \ N);
    开关(event.info。code){
        案SharedObject.Flush.Success:
            跟踪(用户授予权限 - 值存储\ñ。);
            打破;
        案SharedObject.Flush.Failed:
            跟踪(用户权限被拒绝 - 没有保存价值\ñ。);
            打破;
    }
my_so.removeEventListener(NetStatusEvent.NET_STATUS,调用onFlushStatus);
}
 

如果共享对象被阻止U可以否则,如果0它去 SharedObjectFlushStatus.PENDING 错误报告。

<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html"相对=nofollow>来源

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.

解决方案

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

这篇关于软硬度:如何检测,从写作,如果用户已阻止共享对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆