I've been using
SharedObjects in one of my projects this week. I wanted my application to check whether the user accepts SOs, and if not, then pop up a user-friendly explanation of what they are, how to enable them and what information I was going to store, as opposed to popping-up the player settings box without warning and hoping it doesn't alarm them.
However, I found that there were several drawbacks to doing this seemingly simple task.
Flash gives instant feedback to tell you if SOs are disabled, but does not give any further (real-time) feedback when a user changes their settings from 'not allowed' to 'allowed' . There is also the problem of pending changes. Notification of the pending status is returned instantly, but the app needed to wait and find out the result of that decision.
The clearest answer was to use two functions in conjunction with each other. The first takes care of the SO test and the second is called by the first - in the case of pending decisions it is called twice and will redirect to the appropriate frame. This works out as a neat solution to the second problem
As for the first problem the solution is more straight forward. I redirect them to a page with two buttons on: "change settings" (which pops up the settings box at a user-defined time (and as they are expecting it, it will not cause them any alarm)), and a "Refresh" button, which runs the initial check-function again and assesses their new situation.
All this work and only about 10% of users will ever see it. Still, I'm sure Jacob Nielsen would be proud ;)
/******************************
nwebb.co.uk - Shared Objects Checker
******************************/
function checkSO(objName, flushSize) {
mySO = SharedObject.getLocal(objName);
success = mySO.flush(flushSize);
if (success != "pending") {
writeSuccess = success;
}else{
writeSuccess = "pending";
mySO.onStatus = function(result) {
if (result.code == [REMOVE LINEBREAK!]
"SharedObject.Flush.Success") {
writeSuccess = true;
}else{
writeSuccess = false;
}
outcomeSO(writeSuccess);
};
}
outcomeSO(writeSuccess);
}
function outcomeSO(writeSuccess){
trace(writeSuccess);
if(writeSuccess==true){
gotoAndStop(2);
allowSO = true;
}else{
allowSO = false;
}
if(writeSuccess=="pending"){
gotoAndStop(3);
}
if(writeSuccess==false){
gotoAndStop(4);
}
}
//--------------------------
stop();
//call test SO function
checkSO("test", 100);
/*
Linebreak added for blog
formatting reasons. See
[COMMENT]
*/
ARCHIVES

nwebb.co.uk - flash tutorials, php and more.