Writing local SharedObject to swf AS3 and reading it to loaded AS2 swf
I am trying to exchange data between as3 swf and as2 swf that it was downloading. The problem is I can't get my as2 swf to read the localshared object written by as3 swf. It just returns undefined when I try to get a reference to a shared object
// AS3
_SharedObj.objectEncoding = ObjectEncoding.AMF0;
_SharedObj.data.blah = 'str';
_SharedObj.flush(500);
// ... some code to handle the flush status. I verified that the values were flushed.
// AS2
var so = SharedObject.getLocal('somestr', '/');
trace(so); // undefined!
I'm at a loss here. I can read AS2 sharedobject from AS3, but I cannot do it any other way. I have checked that both refer to the same '/' path (specifically localhost, I even checked the physical file on the filesystem - it's in the #localhost directory of the #SharedObjects directory on my mac). ObjectEncoding is set to use AS2 AMF.
It is stated in the docs to set this encoding to allow as2 to access the same shared object, so I guess this means it is possible.
Does anyone have any idea?
source to share
Can't figure out what doesn't work for you, when using FlashDevelop, the following code works great for me:
//AS3
var so : SharedObject = SharedObject.getLocal('somestr', '/');
so.objectEncoding = ObjectEncoding.AMF0;
so.data.blah = 'str';
so.flush();
//AS2
var so = SharedObject.getLocal('somestr', '/');
trace(so.data.blah); // str
source to share