views:

14

answers:

2

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  A: 

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\
www0z0k
Aah! So is there a way to access SharedObjects across swfs??
Yarin
You should only assign relative paths for this...here is the info and link to the related article: Specifying a path - You can use the optional pathname parameter to specify a location for the SharedObject file. This file must be a subdirectory of that domain’s SharedObject directory. For example, if you request an application on the localhost and specify the following: mySO = SharedObject.getLocal("myObjectFile","/");http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d80.html
exoboy
@exoboy - THANKS!
Yarin
@www0z0k - Thanks a lot for your help, but I'll give exoboy the answer because he gives a solution.
Yarin
Thanks! Trust me, I pulled out a lot of my own hair figuring this one out... glad I could save someone else a little pain.
exoboy
i wouldn't try because i never know the username for the full path
www0z0k
+1  A: 

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 reference it and contains a deeper explanation and solution:

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

exoboy