How can I make cookies in my Flash application?

How to make cookies in my Flash application using ActionScript 2.0?

+4
source share
4 answers

You will need to use JavaScript to work with cookies. You can do this from ActionScript using the ExternalInterface API .

+3
source

If you just need local storage and don’t need a specific cookie need, Flash has its own flavor of cookies called SharedObjects . They work more or less the same way, but they are available only for Flash, but nevertheless they will save you from interacting with javascript.

+3
source

In AS2, I would say just create a javascript function to set a cookie and call it from flash using the geturl request.

// Javascript Function function setCookie(c_name,value,expiredays) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } // AS2 Function myBtn_btn.onRelease = function(){ getURL("javascript:setCookie('my_cookie','my_value','30')"); }; 

Hope this helps. chews

ps is unverified code, but it should work :-)

0
source

Flash ActionScript as a proprietary cookie engine called Local Shared Object. you can use the local shared object as cookies, and when you download the same application, you will find the same data that was saved in the previous downloaded application session.

0
source

All Articles