Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Are AS2 and AS3 sharedobjects compatible?

Participant ,
Jul 28, 2009 Jul 28, 2009

I have a legacy AS2 file that stores a nested array in a sharedobject. I have a new file in AS3 that I would like to read and write to that sharedobject. Both swfs will be in use and so should be able to read and write to the same variables in the same sharedobject.  Is that possible?

Here is the code I set up as a test, it is identical in AS2 and AS3...

var so:SharedObject = SharedObject.getLocal("testso", "/");
if(!so.data.arr) so.data.arr = new Array();
trace("retrieved: " + so.data.arr);
so.data.arr = "as2"; // I change this to "as3" when I compile using actionscript 3
so.flush();

I have failed to read the variable in both AS2 and AS3 when it is set by the other, and getting "out of bounds" errors in AS3.

Thanks,

Josh

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 28, 2009 Jul 28, 2009

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html?flash/net/SharedObject.html&fla...

From the help files

objectEncodingproperty
objectEncoding:uint  [read-write]  
Language version: ActionScript 3.0
Player version: Flash Player 9

The object encoding (AMF version) for this shared object. When a local shared  object is written to disk, the objectEncoding property indicates  which Action Message Format version should be used: the ActionScript 3.0 format  (AMF3) or the ActionScript 1.0 or 2.0 format (AMF0).

Object encoding is handled differently depending if the shared object is  local or remote.

  • Local shared objects. You can get or set the value of the  objectEncoding property for local shared objects. The value of  objectEncoding affects what formatting is used for writing this local shared object. If this local shared object must be readable by  ActionScript 2.0 or 1.0 SWF files, set objectEncoding to  ObjectEncoding.AMF0. Even if object encoding is set to write AMF3,  Flash Player can still read AMF0 local shared objects. That is, if you use the  default value of this property, ObjectEncoding.AMF3, your SWF file  can still read shared objects created by ActionScript 2.0 or 1.0 SWF files.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2009 Jul 29, 2009
LATEST

so, why'd you have a problem setting the so using as2 and retrieving it with as3?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines