ExternalInterface Call with AS3 and Javascript
Posted by Stephan Kristyn on November 6th, 2009 / No Comments
I recently came along this problem with ActionScript 3. How to tell Javascript or your DOM what to do from inside of Flash. getUrl threw tons of Security Warnings in Internet Explorer – yes people use that one. fscommand is depreciated.
In AS3 you want to use
ExternalInterface.call
But… that darn thing did not work, no matter what I tried. After 2 hours -which I want to spare you with this post- I found the solution.
The trick was to put the Flash and xhtml Site onto any server environment. A friendly reminder to finally set up that IIS or Apache locally for live testing.
The Code: call your Javascript Function ‘JsTestFunction’ with the string ’2′ and don’t forget putting your files on your server.
var call_JS:uint;
call_JS = ExternalInterface.call('JsTestFunction','2');
Tested with Firefox 3.5, IE8 RC1, Chrome 3, Opera 10 on Win7 RC1