AS3 共享对象会减慢 swf 速度并导致网页无响应
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,Flash 中的共享对象非常慢。话虽这么说,但它没有理由在使用后会减慢整个网站的速度。
当写入SO时,必须使用flush()来告诉Flash实际写入数据。
另一件可以尝试的事情是在完成连接后主动关闭连接。因此,在 else 语句之后,您需要添加:
如果这不起作用,下一步将是在 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.
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:
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.