Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you just want to store and retrieve data, you probably want to use the SharedObject class. See <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html" rel="noreferrer">Adobe's SharedObject reference</a> for more details of that.</p> <p>If you want to access the HTTP cookies, you'll need to use ExternalInterface to talk to javascript. The way we do that here is to have a helper class called HTTPCookies.</p> <p>HTTPCookies.as:</p> <pre><code>import flash.external.ExternalInterface; public class HTTPCookies { public static function getCookie(key:String):* { return ExternalInterface.call("getCookie", key); } public static function setCookie(key:String, val:*):void { ExternalInterface.call("setCookie", key, val); } } </code></pre> <p>You need to make sure you enable javascript using the 'allowScriptAccess' parameter in your flash object.</p> <p>Then you need to create a pair of javascript functions, getCookie and setCookie, as follows (with thanks to <a href="http://www.quirksmode.org/js/cookies.html" rel="noreferrer">quirksmode.org</a>)</p> <p>HTTPCookies.js:</p> <pre><code>function getCookie(key) { var cookieValue = null; if (key) { var cookieSearch = key + "="; if (document.cookie) { var cookieArray = document.cookie.split(";"); for (var i = 0; i &lt; cookieArray.length; i++) { var cookieString = cookieArray[i]; // skip past leading spaces while (cookieString.charAt(0) == ' ') { cookieString = cookieString.substr(1); } // extract the actual value if (cookieString.indexOf(cookieSearch) == 0) { cookieValue = cookieString.substr(cookieSearch.length); } } } } return cookieValue; } function setCookie(key, val) { if (key) { var date = new Date(); if (val != null) { // expires in one year date.setTime(date.getTime() + (365*24*60*60*1000)); document.cookie = key + "=" + val + "; expires=" + date.toGMTString(); } else { // expires yesterday date.setTime(date.getTime() - (24*60*60*1000)); document.cookie = key + "=; expires=" + date.toGMTString(); } } } </code></pre> <p>Once you have HTTPCookies.as in your flash project, and HTTPCookies.js loaded from your web page, you should be able to call getCookie and setCookie from within your flash movie to get or set HTTP cookies.</p> <p>This will only work for very simple values - strings or numbers - but for anything more complicated you really should be using SharedObject.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload