ColdFusionKing
Programmer
Hi Guys, I want to know how to read cookies in Flash MX.
I'm embedding my flash movie on the html page, have added JavaScript to create a cookie which stores the username and password, I then want to send this information using URL variables to the flash movie and read the data using actionscript and authenticate the user.
Here is my code, I've knicked most of the logic to read and pass the cookie to flash in JavaScript from this site:
Here is the code:
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
createCookie("Username","testUser"
;
createCookie("Password","testPassword"
;
function createCookie(name,value) {
var expireday = new Date();
expireday.setTime(expireday.valueOf() + 1000*3600*24*365);
document.cookie = name + "=" + value + "; expires=" + expireday.toGMTString() + ";";
}
// Get Cookies script
cookString = "?"
// does the visitor have a cookie?
if(document.cookie != ""
{
theCook = document.cookie.split("; "
// add each part of the cookie to a string variable
for (i = 0; i < theCook.length; i ++) {
cookString += theCook + "&"
}
}
// Name the variables
flName = "myFlashmovie.swf"
flColor = "#99cc99"
flHeight = "300"
flWidth = "400"
// This portion of the script is a modified version of Colin Moock's
// flash cookie importer, query string version script.
// Slight modifications have been made to
// work with the get cookies script.
document.write('<OBJECT '
+ 'classid="clsid
27CDB6E-AE6D-11cf-96B8-444553540000"'
+ 'codebase=" + 'cabs/flash/swflash.cab#version=6,0,0,0"'
+ ' ID="graph"'
+ ' WIDTH=680'
+ ' HEIGHT=600>'
+ '<PARAM NAME=movie VALUE="' + flName + cookString + '">'
+ '<PARAM NAME=quality VALUE=high>'
+ '<PARAM NAME=bgcolor VALUE=#FFFFFF>'
+ '<EMBED src="myFlashmovie.swf' + cookString + '"'
+ ' name="flash"'
+ ' quality=high bgcolor=#FFFFFF'
+ ' WIDTH=680'
+ ' HEIGHT=600'
+ ' TYPE="application/x-shockwave-flash"'
+ ' PLUGINSPAGE=" + '</EMBED></OBJECT>'
)
// -->
</SCRIPT>
If someone's got a better solution to do this, then please let me know.
Could somebody show me how to read the URL variables in Flash MX?
I'm embedding my flash movie on the html page, have added JavaScript to create a cookie which stores the username and password, I then want to send this information using URL variables to the flash movie and read the data using actionscript and authenticate the user.
Here is my code, I've knicked most of the logic to read and pass the cookie to flash in JavaScript from this site:
Here is the code:
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
createCookie("Username","testUser"
createCookie("Password","testPassword"
function createCookie(name,value) {
var expireday = new Date();
expireday.setTime(expireday.valueOf() + 1000*3600*24*365);
document.cookie = name + "=" + value + "; expires=" + expireday.toGMTString() + ";";
}
// Get Cookies script
cookString = "?"
// does the visitor have a cookie?
if(document.cookie != ""
theCook = document.cookie.split("; "
// add each part of the cookie to a string variable
for (i = 0; i < theCook.length; i ++) {
cookString += theCook + "&"
}
}
// Name the variables
flName = "myFlashmovie.swf"
flColor = "#99cc99"
flHeight = "300"
flWidth = "400"
// This portion of the script is a modified version of Colin Moock's
// flash cookie importer, query string version script.
// Slight modifications have been made to
// work with the get cookies script.
document.write('<OBJECT '
+ 'classid="clsid
+ 'codebase=" + 'cabs/flash/swflash.cab#version=6,0,0,0"'
+ ' ID="graph"'
+ ' WIDTH=680'
+ ' HEIGHT=600>'
+ '<PARAM NAME=movie VALUE="' + flName + cookString + '">'
+ '<PARAM NAME=quality VALUE=high>'
+ '<PARAM NAME=bgcolor VALUE=#FFFFFF>'
+ '<EMBED src="myFlashmovie.swf' + cookString + '"'
+ ' name="flash"'
+ ' quality=high bgcolor=#FFFFFF'
+ ' WIDTH=680'
+ ' HEIGHT=600'
+ ' TYPE="application/x-shockwave-flash"'
+ ' PLUGINSPAGE=" + '</EMBED></OBJECT>'
)
// -->
</SCRIPT>
If someone's got a better solution to do this, then please let me know.
Could somebody show me how to read the URL variables in Flash MX?