ActionScript 3 SharedObjects don't persist acr

2019-02-28 14:15发布

I am serving two different swfs that read and write to the same SharedObject variable. The SharedObject variable is a number, and each swf checks that number to make sure it isn't using the same number twice. It then stores the last number it selects. In this way both swfs should never use the same number twice, no matter which order they're loaded.

If I repeatedly load one of the swfs, the never-twice rotation works. However, when switching back and forth between swfs, sometimes the number is repeated. SharedObjects are supposed to be global to the Flash Player, so why would this happen?

Thanks

2条回答
孤傲高冷的网名
2楼-- · 2019-02-28 14:29

SharedObjects are filename-specific and location-specific the root path is:

C:\Users\username\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\436UUXWX\

but for www.example.com/res/flash/file1.swf and www.example.com/res/flash/file2.swf it will be:

C:\Users\username\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\436UUXWX\www.example.com\res\flash\file1.swf\

and:

C:\Users\username\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\436UUXWX\www.example.com\res\flash\file2.swf\
查看更多
淡お忘
3楼-- · 2019-02-28 14:44

Shared Objects are actually given their own folder so that they do not potentially collide with another SO of the same name. If you want to have multiple SWF's access a single SO, then you need to specify an actual path for the SO instead of allowing Flash to create one for you. This forces the SWF to read/write the same SO.

Here is the article that contains a deeper explanation and a few different solutions:

http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d80.html

查看更多
登录 后发表回答