AS3 共享对象会减慢 swf 速度并导致网页无响应

发布于 2024-10-19 03:03:39 字数 441 浏览 1 评论 0原文

我有一个 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);
} 

预先非常感谢 雷切尔

I have a swf that I would like to cookie to control the frame the user see's depending on whether it is a first time site visit or returned visit. My code is below - it works, it doesn't bring back any out messages however when I load the swf into my site that uses this technique the page becomes extremely slow and unresponsive - can anyone help out with any reasons why this may occur?

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);
} 

Many thanks in advance
Rachel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-10-26 03:03:39

一般来说,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 中及其周围放置跟踪语句,并确保在程序运行时它们不会被访问。

SharedObjects in general are extremely slow in Flash. That being said, there is no reason why it should be slowing down your entire site after it has been used.

When writing to a SO, you have to use flush() to tell Flash to actually write the data.

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

Another thing to try would be to actively close the connection after you are done with it. So after the else statement you would add:

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

If that doesn't work, the next steps would be to put trace statements in and around the SOs and make sure they aren't being accessed while the program is running.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文