Using Flash local shared Object !

19 01 2007

If you have experienced web Development (PHP ASP Etc), then you must know what cookies are !
they are like containers that are used to store users information on their machine while browsing  a particular site , it can contain anything the developer specify (username , encrypted passwords , date , time , etc …) .

Now meet the flash cookies AKA local shared objects , its as well used to save user data .
We had a case scenario discussed back at Designersblock

Brief : Suppose you had a flash banner html embed that has a sound running in the background & it can be turned on/off .
A user turns off the sound , but when he clicks a link to another page on the same site , the banner starts the music again , so how to avoid this ? Ohh ya Local shared  object !! before i start , a good simple tutorial about LSO can be found HERE.
here is how :

 var Mysound:Sound = new Sound();
local_data = SharedObject.getLocal(“user_data”);
Mysound.attachSound(“track1”);
checkSound();
this.onEnterFrame = function() {
if(local_data.data.CheckStatus == undefined){
local_data.data.CheckStatus == “on”
checkSound();
delete this.onEnterFrame;
}
}

function checkSound() {
if(local_data.data.CheckStatus == “on”){
Mysound.start();
}else{
Mysound.stop();
}

}
On_button.onPress = function() {
if(local_data.data.CheckStatus != “on”){
local_data.data.CheckStatus =”on”;
local_data.flush();
checkSound();
}
}
Off_Button.onPress = function() {
if(local_data.data.CheckStatus != “off”){
local_data.data.CheckStatus =”off”;
local_data.flush();
checkSound();
}
}

Advertisements