AS3共享对象减慢了swf并使网页无响应

时间:2011-02-25 12:18:37

标签: actionscript-3 object cookies flash-cs4 shared

我有一个swf,我想cookie来控制用户看到的帧,这取决于它是第一次访问网站还是返回访问。我的代码在下面 - 它的工作原理,它不会带回任何输出消息但是当我将swf加载到使用这种技术的网站时,页面变得极其缓慢且无响应 - 任何人都可以帮助解决为什么会出现这种情况的原因吗?

var my_so:SharedObject = SharedObject.getLocal("visited", "/");

if (my_so.data.newVisitor != undefined) {
//object exists: return user
this.gotoAndPlay(2);


} else {
//object doesn't exist: new user
my_so.data.newVisitor = "no";
this.gotoAndStop(1);
} 

非常感谢提前 拉结

1 个答案:

答案 0 :(得分:1)

共享对象通常在Flash中非常慢。话虽如此,没有理由说它在使用之后应该减慢整个网站的速度。

写入SO时,必须使用flush()告诉Flash实际写入数据。

my_so.data.newVisitor = "no";
// Write the data to disk
my_so.flush();

尝试的另一件事是在完成连接后主动关闭连接。所以在else语句之后你会添加:

// Close the connection
my_so.close();
// Clear pointer for GC
my_so = null;

如果这不起作用,接下来的步骤是在SO中和周围放置跟踪语句,并确保在程序运行时不访问它们。