I partly agree with PatrickS; the functionality you desire should be thought of as a set of distinct processes. But I think the size of that set is 3, not 2:
- A process capable of inserting and retrieving data in a database
- A process capable of transmitting data between a client and a server
- A process capable of inserting and retrieving data in a LSO
So no, LSO data cannot be created or accessed by the server. It can, however, be created or accessed (and sent back) on behalf of the server. And that is best done with the use of ExternalInterface
, like so:
- Encapsulate in a method, the Actionscript code which handles the LSO data.
- Register the method with the external interface of the prospective Flash application it is defined in using
ExternalInterface.addCallback()
.
- Compile the Flash application, and create an element in your HTML that references the resultant .swf file.
- Create a
DOMElement
representation of the HTML element, and call the method in #1, which should now be defined as a member of the DOMElement
.
Check out BakedGoods if you don't want to go through the trouble of doing all of this; its a Javascript library that establishes a uniform interface that can be used to conduct common storage operations in all native, and some non-native storage facilities, including Flash Locally Shared Objects.
With it, creating an LSO can be accomplished with code as simple as:
bakedGoods.set({
data: [{key: "key", value: "value"}],
storageTypes: ["flash"],
complete: function(byStorageTypeRemovedItemKeysObj, byStorageTypeErrorObj){/*code*/}
});
Retrieving and removing data is just as easy. Trust me on all of this, I would know; i'm its maintainer :)