3

I'm new Adobe Animate programmer, I like to ask experienced ActionScripts 3 developers, Is there any default and simple way to store preferences data in ActionScripts3 like UNITY3D (PlayerPrefs)? or not what is easiest way that works without modification for cross platform AIR?

Which one is better and simpler:

1.Text file.

2.XML file.

3.JSON file.

4...?

Ali Kazemi
  • 505
  • 7
  • 19
Sepanta SS
  • 41
  • 4

2 Answers2

2

SharedObject seems to fit the description perfectly

The SharedObject class is used to read and store limited amounts of data on a user's computer or on a server. Shared objects offer real-time data sharing between multiple client SWF files and objects that are persistent on the local computer or remote server. Local shared objects are similar to browser cookies and remote shared objects are similar to real-time data transfer devices. To use remote shared objects, you need Adobe Flash Media Server.

www0z0k
  • 4,444
  • 3
  • 27
  • 32
  • `SharedObject` is the easiest in Flash Player but you have to worry about maximum allowed size and whether the user has disabled SOs completely. Using AIR it's actually quite easier to just use `EncryptedLocalStore` or writing to an AMF file where those restrictions don't apply. – Aaron Beall Feb 01 '17 at 13:01
2

SharedObject is ActionScripts default and easiest way to store basic data, It is very similar to Unity3D (PlayerPrefs). But SharedObject data size is limited to 100KB, Unity3D PlayerPrefs is limited to 1000KB.

This is simple codes to use SharedObject:

var DATA:SharedObject = SharedObject.getLocal("DATA_STORAGE");//Create SharedObject

DATA.data.Data1 = "111";//Set Data 1
DATA.data.Data2 = "222";//Set Data 2

DATA.flush();//Write data

trace(DATA.data.Data1);//Read Data 1
trace(DATA.data.Data2);// Read Data 2

//DATA.clear();//Clear all data
Ali Kazemi
  • 505
  • 7
  • 19
  • Actually the size limit is configurable by user from 0 to much more than 100kb, 100kb is just the default size. If the user hasn't disabled SOs completely you can query for user to allow more space using `flush(minDiskSpace)`. – Aaron Beall Feb 01 '17 at 13:00
  • Thanks for your information. – Ali Kazemi Feb 01 '17 at 13:40