|
|
|
Flash4 Cookie Tutorial and HTMLTemplate First be aware. Also, be sure to test with cookies disabled to make sure that your movie degrades gracefully if cookies are turned off. So how do you use the cookieJar HTML template? Before you publish your fla, go to File/Publish on the menu. Choose the HTML tab and change the Template to CookieJar. When you want to update the value of the cookie send an FS Command with "setCookies" as the command and the string you want to save as the argument. For example this code could be put in a button.
Clicking this button would then set the value of the cookie to the string "Peanut Butter". The Javascript code will then also update the "/:CookieJar" variable in Flash to "Peanut Butter" as well. The code tells the cookie to persist for a year from the last time it was set. I would suggest that you don't use the "/:CookieJar" variable directly as the second argument in the call to FS Command. If you want to use a variable, create it separately, calling it "/:CookieValue", for example. That would make it easier to debug and also would avoid situations where Javascript and ActionScript both are trying to change the CookieJar variable at the same time. So you would write to CookieValue and send that to the JavaScript code. The JavaScript code writes to CookieJar which you only read from. There is an example .fla that you can use to examine this more. You can look at it here. So how does it work? Now the Flash movie can call the FSCommand function further with "setCookies" and "a string value" as described above, which will update the cookie value to what was set. cookieJar.html template
- this is a blank HTML template so use "view source" |
| My Portrait | On Process | Space Opera | Of Twilight |
| My Work | On Art | Entropy Island | A Fermented Jig |
| Resume | Journal | Eroica | |
| Mail Me? | Flash Things | ||