LittleRed
11-14-2003, 10:12 AM
I wanted to have a cookie set when a certain page was visited so that a Flash movie on another page would know if this page had been visited or not, and alter the content accordingly.
I've set the cookie on the non-flash page with:
var mazecookie = "visitedmaze=set";
document.cookie = mazecookie;
and then called the flash object on the other page with javascript and sending the cookie as a query. So in the <HEAD> I have:
readmazecookie = "notset";
if(document.cookie !="") {
readmazecookie = document.cookie;
splitmazecookie = readmazecookie.split(";");
readmazecookie = splitmazecookie[0];
splitmazecookie = readmazecookie.split("=");
readmazecookie = splitmazecookie[1];
}
and the <BODY> has
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="550" height="400">')
document.write('<param name="movie" value="reading_cookie.swf?visitedmaze='+readmazecookie+'">')
document.write('<param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF">')
document.write('<embed src="reading_cookie.swf?visitedmaze='+readmazecookie+'"')
document.write('quality="high" bgcolor="#FFFFFF" width="550" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>')
document.write('</object>')
The Flash movie then checks the variable 'visitedmaze' to see if it equals 'set' or not.
is this the best way to do it? I found I had to do the couple of .splits in the header so that it was just the value of the cookie that was passed through to the Flash movie. Otherwise I ended up with the value of the variable being visitedmaze='set' and not just set
thanks
I've set the cookie on the non-flash page with:
var mazecookie = "visitedmaze=set";
document.cookie = mazecookie;
and then called the flash object on the other page with javascript and sending the cookie as a query. So in the <HEAD> I have:
readmazecookie = "notset";
if(document.cookie !="") {
readmazecookie = document.cookie;
splitmazecookie = readmazecookie.split(";");
readmazecookie = splitmazecookie[0];
splitmazecookie = readmazecookie.split("=");
readmazecookie = splitmazecookie[1];
}
and the <BODY> has
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="550" height="400">')
document.write('<param name="movie" value="reading_cookie.swf?visitedmaze='+readmazecookie+'">')
document.write('<param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF">')
document.write('<embed src="reading_cookie.swf?visitedmaze='+readmazecookie+'"')
document.write('quality="high" bgcolor="#FFFFFF" width="550" height="400" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>')
document.write('</object>')
The Flash movie then checks the variable 'visitedmaze' to see if it equals 'set' or not.
is this the best way to do it? I found I had to do the couple of .splits in the header so that it was just the value of the cookie that was passed through to the Flash movie. Otherwise I ended up with the value of the variable being visitedmaze='set' and not just set
thanks