flash.net.SharedObject
Created By Ted Patrick - 1 Comments Published by Friday, October 12, 2007 at 2:46 AM ."Cookies are to the Browser as SharedObject is to Flash Player/AIR."
SharedObject allows you to persist data in object form on the client side in Flash Player or AIR. It is an incredibly simple class with some profound implications when used properly. Since Flash Player 6 you have been able to persist data using SharedObject to disk on the end users machine, you cannot write arbitrary files but you can store up to 100K of data in object form which is pretty cool.
API DOCUMENTATION
EXAMPLE:
var so:SharedObject = SharedObject.getLocal("scores");
so.data.highScore = new Number(892343);
so.data.lowScore = new Number(5934);
so.data.recentScore = new Number(382234);
so.data.gamerName = new String("adobeted");
so.flush();
MORE:
You create or open a SharedObject using the getLocal method with a unique path or domain. SharedObjects can only be read on domains where they are set so they have a handy security implication that is being used at Bank of America, Yahoo and other sites for extra security on web transactions. The security model for SharedObject is located here
Once you have a SharedObject instance you simply write data into the data object. When the Flash Player/AIR instance quits all SharedObject data is flushed to disk but you can force writing to disk using the flush() method.
SharedObject data can also be synchronized using the RTMP protocol and are the primary data exchange technique for use with Flash Communication Server.
USES:
- Tracking users with a GUID
- Persisting username for login fields
- Storing UI state
- Storing history for local user
- Synchronizing data between clients (FMS via RTMP)
- Store any data between requests
Hidden APIS
I am firing up the "Hidden API" Blog. If you are interested in contributing to Hidden APIS, please contact me at ted@adobe.com. I am looking for various opinions on the different APIS as my perspective is far from the only one that matters. I think we can all learn a ton about the lower level features of Flash Player/AIR/Flex/Flash here sharing how the various APIS are used. Hidden APIS should be a fun long term project and now that I have time, lets get this party started.
Cheers,
Ted :)
Good job, thank you.