views:

436

answers:

2

Has anyone used Flash's SharedObject mechanism for client-side persistence? Are there big gatcha's? Size limits?

A: 

Things you ought to remember about SharedObjects documentation:

  • They do not expire by default.
  • By default, they are limited to a size of 100 KB each.
  • They can store simple data types (such as String, Array, and Date).
  • They are stored in a location specified by the application (within the user's home directory).
  • They are never transmitted between the client and server.
  • Use getLocal() to create a shared object. (SharedObject.getLocal("myTasks"); )
  • Use flush() to write the shared object to the client file. (sharedObj.flush())
  • Use clear() to destroy a shared object (sharedObj.clear())

Also, note that the location where the data is saved depends on the browser being used.

So yes, this is definitely good for storing simple data.

dirkgently
+2  A: 

SharedObjects with AS3 is very easy, but yes here are a few thing to watch out for. But nothing too serious.

  • Size Limit. Yes there is a 100kb limit per site. When this limit is reached the user gets a small popup asking to increase the limit for your site only. You can change your own limit by right clicking on an embeded SWF and going to "Settings>Local Storage".

  • DataTypes. You can store any datatype that works in Flash.

  • Debugging. Often it is useful for debugging to get a look at what is actually being stored in the shared object. There are many tools for this, but I would recommend SharedObject Reader from Sephiroth. There is also a version of this that comes With FlashDevelop.

  • Security. There is almost no "security" with SharedObjects, they are basically a text file with no encryption, so don't use them to store a uses username and password. But remember that only the site that creates the SharedObject will have access to it (and anyone/anything with file-system access).

  • Location. You can find the actual .SOL files (on Windows XP) at "C:/Documents and Settings/[USERNAME]/Application Data/Macromedia/Flash Player/#SharedObjects/"

  • Reset. I have found that quite often my SharedObject will stop work because during development, broken data has been stored. In this case the best thing is just to delete the .SOL file and start fresh.

Hope this helps. A would definitly read HOWTO: SharedObjects for Local Storage AS3 for more information on how to actually use SharedObjects.

TandemAdam