Flash Shared Objects in OpenLaszlo

Flash Shared Objects came up in a discussion today, and I wondered if they would be useful to OpenLaszlo developers. Shared Objects are a Flash feature that work like browser cookies. You create one of these objects to store information across multiple visits to the same application by the same client. e.g. You may want to save the user’s username, so they don’t have to re-type it when visiting the site a second time.

Referencing the SharedObject object is easy. In LZX, when compiling to the Flash runtime, you can call ActionScript objects directly from LZX code. It’s not recommended that LZX developers get into the habit of doing this: it’s not portable to other runtimes, and isn’t supported by Laszlo Systems.

I decided to write a class (lzsharedobject) that encapsulated a single Shared Object, and exposed its value through a “value” attribute. This has a few advantages over sprinkling calls to the ActionScript objects directly:

  • If DHTML-runtime support is needed in future, we have a central place to add some runtime conditionals, and switch to using some other trick (e.g. browser cookies) to handle persisting the saved value.
  • The coding style is declarative. There is a tag called , which makes for cleaner, more expressive code.
  • You get all the nifty OpenLaszlo-y-ness. e.g. You can constrain to the “value” attribute.

Here’s the application in action. Note that the value of the Shared Object will be “undefined” the first time around. Be sure to try reloading the browser:

... and you can download the source code.

4 thoughts on “Flash Shared Objects in OpenLaszlo

  1. Hey Alex,

    Thanks for pointing that out. I’ve corrected the link that “download the source code” points to. You should be able to download the source code as a zip now.

    -Antun

Leave a Reply

Your email address will not be published. Required fields are marked *