Welcome to Mediasparkles

News : Flash

Shared local objects


When I read Advanced PHP for Flash, I was first introduced to local shared objects in Flash and have been in love with them ever since. Last night I set up a shared local object for my electronic music quiz to give users the option of remembering their login information. It is very, very simple to do this. During login state initialization, I have this code:

login_so = SharedObject.getLocal('quizLogin');
if (login_so.data.username != undefined) {
username_txt.text = login_so.data.username;
password_txt.text = login_so.data.password;
}


First, I access the shared object ("so"), whether it already exists or not. If the so's data contains a variable named username, I fill in the username and password information that has been stored previously on the user's machine.
At login, I store in the so the username and password the user entered to be accessed the next time the user visits. This is done like so:

login_so = SharedObject.getLocal('quizLogin');
login_so.data.username = username_txt.text;
login_so.data.pass = password_txt.text;
login_so.flush();


And that's it! You might want to put in some conditionals and let the user decide whether to save the login data to a shared object or not. But the shared object code alone really is that simple.

 posted by Vera (3/31/2003 09:44:00 PM);




My friend Starrie had the great idea to greet my site visitors with updates on what I am up to professionally. Enter MediaSparkles version 3.0. I have set up a mini blog to which I will post projects I am working on and my thoughts on Flash and related technologies. If you're looking for the old cubes and bubbles that used to live here, they have moved here.

 posted by Vera (3/30/2003 05:21:00 PM);