Reputation: 1120
I have a flash swf object that gets embedded in the facebook news feed. I can't control anything other than the swf file itself. Its hosted on our server and I need to be able to read a cookie our main website sets.
Everything I can find talks about using external javascript to read and set the cookie, but I want to do it from inside of flash itself.
Upvotes: 0
Views: 1391
Reputation: 385
You can actually do a lot more with ExternalInterface than people realize. Define your function in AS3, and then pass it to ExternalInterface as a parameter in an ExternalInterface.call. I built a simple AS3 project with this as a property of the main class.
private var myTestJS:String = "function myTest(parameter){alert(parameter);return parameter;}";
and this in the constructor
var mycookievalue:String = ExternalInterface.call(myTestJS, "Yay for ExternalInterface");
Build a quick project, debug that and you'll see that both the alert gets called as well as mycookievalue gets set correctly. Now, you just need to replace my test function with your js code to pick up the cookie.
Upvotes: 2
Reputation: 39408
Flash Player can't access browser cookies. The ExternalInterface approach is a trick to get JavaScript to do it for you.
Flash Player can access Shared Objects, which are like the Flash Player's version of cookies; but generally Flash and the browser do not share cookies.
Upvotes: 0