Hmmm...Cookies! Double chocolate is my favourite...
Ok.... Flash Cookies!
You don't need a javascript... In fact, even if someone has disabled javascripts, a flash cookie will still work!
There is no way to disable flash cookies on ALL sites. You can disable them on individual sites that you specify however, by right-clicking and choosing "settings". Then if you click on the second tab "Local Storage" you can change what flash can and can't store.
But onto the actual scripting!
Ok, you have to create a shared object in flash, which you can then read to and write from (as much data as you want). Technically, you could store a book in there if the user allowed you to store that much data, but we want one variable, such as "visited_before" or something similiar, that flash can check and, if it is equal to "here", then the movie can take appropriate action, such as not playing and instead redirecting to an url.
- Code: Select all
_root.shareObj = SharedObject.getLocal("shareObj");
if (_root.shareObj.data.check == "here") {
stop();
getURL("page.html");
} else {
trace("Writing Shared Object (Flash Cookie)...");
_root.shareObj.data.check = "here";
_root.shareObj.data.flush();
}
This code checks if the variable "check" (in the shared object) is equal to the text "here" and, if it is, it stops the movie and gets the page.
html url.
If the variable is not equal, or not there (the else clause) then the code writes the variable and flushes (writes) the data to the cookie object.
You can find an example here:
Flash
FLA:
http://www.digital-end.com/webforumz...ash_cookie.fla
Online Example:
http://www.digital-end.com/webforumz...sh_cookie.html
Hope this helps!! lol... It's some very useful stuff! Remember you can store anything in there, including, for example, user details or preferences!