Reputation:
How can I make cookies in my Flash application using ActionScript 2.0?
Upvotes: 4
Views: 4185
Reputation: 471
Flash ActionScript as own Cookies Mechanism which called Local Shared Object. you can use Local Shared Object as a cookies and when you will load once again same application you will find out the same data which stored in previous loaded application session.
Upvotes: 0
Reputation: 2659
In AS2, I would say just create a javascript function to set the cookie and call it from within flash using a 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 that helps. chews
p.s. that is untested code but it should work :-)
Upvotes: 0
Reputation: 27045
If you just need local storage and don't have a specific need for cookies Flash has it's own flavour of cookies called SharedObjects. They work more or less the same but they're only readable from Flash, they will however save you the bother of interfacing with javascript.
Upvotes: 3
Reputation: 1846
You would need to use JavaScript to work with cookies. You can do so from ActionScript using the ExternalInterface API.
Upvotes: 3