Macabre Machinery
July 5, 2000
Okay, so the document is loaded and the object "document.flashfile"
has been created. We go to flashReadCookie():
//set the read and parse functions in motion,
//then send cookie info to Flash
function flashReadCookie()
//check to see if the cookie exists already
var check=document.cookie;
//is our cookie already on the user's machine?
if (check.indexOf(cookieName) == -1)
{
//our cookie is not on the user's machine
//cookieYes function tries to write a cookie
//and sets acceptsCookies accordingly...
cookieYes();
//user accepts cookies - go to options in Flash Movie
if (acceptsCookies == true){document.flashfile.GotoFrame(4);}
//user does not like cookies. send him away.
else {document.flashfile.GotoFrame(9);}
}
//our cookie is there already - go ahead and send
//the cookie variables to Flash
else
{
//make an associative array called 'cookieInfo'
var cookieInfo = new Array();
readTheCookie(cookieInfo);
document.flashfile.SetVariable("headlines",cookieInfo["headlines"]);
document.flashfile.SetVariable("sports",cookieInfo["sports"]);
document.flashfile.SetVariable("entertainment",cookieInfo["entertainment"]);
document.flashfile.SetVariable("background",cookieInfo["background"]);
document.flashfile.GotoFrame(2);
}
}
This is pretty well commented, but here is the logic in a nutshell:
- Load the cookie - is our cookie in there?
- If it is not, we check to see if the user even accepts cookies
(the cookieYes function).
- If the user does accept cookies, we send him to the part of
the Flash movie where he can give us the data with which to build
the cookie. (1)(2)
- Suppose someone actually did come back to our site. We build
an associative array (do they call it a "hash" in
JavaScript)? called cookieInfo to hold the key:value pairs in the
cookie. (See comments in these functions for explanation, or go
right to the
source).
- Now that readTheCookie and its minions returned the tidy array
cookieInfo, we can send the variable values back to the Flash player,
and send it to the frame where the user will see his preferred
headlines.
Bride of Flashenstein
Bride of Flashenstein
The Bolts
|