ActionScript 3 SharedObjects don't persist across different swfs?

老子叫甜甜 提交于 2019-12-04 05:07:10

问题


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


回答1:


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




回答2:


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\


来源:https://stackoverflow.com/questions/3981777/actionscript-3-sharedobjects-dont-persist-across-different-swfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!