August 30, 2006

Saving user info to the Flash Player to retrieve later

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 8:20 pm

A quick article on using the Flash Shared Object which allows you to ‘persist’ or save a variable that can be retrieved from the flash player when a visitor returns - view here.

In short, we use the shared object like this:

// Create the shared object
mySharedObject = SharedObject.getLocal("myUniqueObjectKey");
 
// Use the object to dynamicall set whichever variables and values we need
mySharedObject.myValueToRetrieveLater =  "Hello World!"; // how corny
 
// Save/Write the Shared Object data to the flash player
mySharedObject.flush();

We read in a value like below:

// Create the shared object again, it will automatically load any of the last flushed values
mySharedObject = SharedObject.getLocal("myUniqueObjectKey");
 
// Trace it to see if we have a value that we wanted to retrieve
trace(mySharedobject.myValueToRetrieveLater);

We could apply this in a lot of ways; one being a log in form, where you may want to remember the last logged in user for accessibility of your website visitor. Ensure that you don’t save the password too though!

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Furl
  • Reddit
  • YahooMyWeb

3 Comments »

  1. On ActionScript.org there is an article discussing Enabling the back button within flash. The whole process looks rather cumbersome involving a few scripts, but here is the link:
    http://www.actionscripts.org/tutorials/intermediate/Enabling_a_back_button_within_flash/index.shtml

    Original Concept of the back button: Robert Penner
    http://www.robertpenner.com/experiments/backbutton/backbutton_code.html

    Communicating with Flash using JS
    http://www.mustardlab.com/developer/flash/jscommunication/

    Comment by Cameron Manderson — August 30, 2006 @ 8:33 pm

  2. Customising the Context Menu (when you right click) in Flash
    http://www.albinoblacksheep.com/tutorial/contextmenu

    Comment by Cameron Manderson — August 30, 2006 @ 8:45 pm

  3. They shared object is excellent for creating “remember me” functionality for user login or to even store user system infomation such as player version.

    Comment by Richard Lee — August 31, 2006 @ 9:52 am

RSS feed for comments on this post. TrackBack URI

Leave a comment