//Shared Objects [v1.0]
//Sample
//Facts
/////////////////////////////////////////
// START / frame1 / frame label 'edit' //
/////////////////////////////////////////
//[section]:edit
trace('edit');
hdrTxt.text = '//edit data';
//[vars]:txt
nameTxt.text = 'enter name'; trace(nameTxt)
emailTxt.text = 'enter email'; trace(emailTxt)
//[shdObj]:check it
var userData = SharedObject.getLocal("fileX", "/");
if (userData.data.namex != undefined){
gotoAndStop('sav');
}
//[shdObj]:save func
function shdObjSav(){
trace("saved oBjs");
var userData = SharedObject.getLocal("fileX", "/");
userData.data.namex = nameTxt.text;
userData.data.emailx = emailTxt.text;
gotoAndStop('sav');
}
//[btn]:save
savBtn.onRelease = function() {
trace("save btn");
gotoAndStop("save");
shdObjSav();
};
//
stop();
///////////////////////
// END CODE / frame1 //
///////////////////////
/////////////////////////////////////////
// START / frame2 / frame label 'save' //
/////////////////////////////////////////
//[section]:save
trace('save');
hdrTxt.text = '//saved data';
//[shdObj]:read data
var userData = SharedObject.getLocal("fileX", "/");
nameTxt.text = userData.data.namex;
emailTxt.text = userData.data.emailx;
//[btn]:delete
delBtn.onRelease = function(){
trace("delete");
userData.clear();
gotoAndStop("edit");
};
//
stop();
///////////////////////
// END CODE / frame2 //
///////////////////////
//Download
shdObj_v1.rar
//Facts
- path: Shared objects are stored locally on the users machine here is the path: C:\Documents and Settings\[login name]\Application Data\Macromedia\Flash Player\#SharedObjects\ (within the '#SharedObjects' file browse for a folder 'localhost' for local testing if testing remotely locate URL name i.e. 'servername.com' etc. within that file there will be a file labeled 'fileX.sol').
- size: shared objects can only store 100KB from each URL thereafter it overwrites it.
- extension: .SOL = Local Shared Object (stands for).
/////////////////////////////////////////
// START / frame1 / frame label 'edit' //
/////////////////////////////////////////
//[section]:edit
trace('edit');
hdrTxt.text = '//edit data';
//[vars]:txt
nameTxt.text = 'enter name'; trace(nameTxt)
emailTxt.text = 'enter email'; trace(emailTxt)
//[shdObj]:check it
var userData = SharedObject.getLocal("fileX", "/");
if (userData.data.namex != undefined){
gotoAndStop('sav');
}
//[shdObj]:save func
function shdObjSav(){
trace("saved oBjs");
var userData = SharedObject.getLocal("fileX", "/");
userData.data.namex = nameTxt.text;
userData.data.emailx = emailTxt.text;
gotoAndStop('sav');
}
//[btn]:save
savBtn.onRelease = function() {
trace("save btn");
gotoAndStop("save");
shdObjSav();
};
//
stop();
///////////////////////
// END CODE / frame1 //
///////////////////////
/////////////////////////////////////////
// START / frame2 / frame label 'save' //
/////////////////////////////////////////
//[section]:save
trace('save');
hdrTxt.text = '//saved data';
//[shdObj]:read data
var userData = SharedObject.getLocal("fileX", "/");
nameTxt.text = userData.data.namex;
emailTxt.text = userData.data.emailx;
//[btn]:delete
delBtn.onRelease = function(){
trace("delete");
userData.clear();
gotoAndStop("edit");
};
//
stop();
///////////////////////
// END CODE / frame2 //
///////////////////////
//Download
shdObj_v1.rar
Labels: action script, flash, shared objects
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home