ExternalInterface API Examples
Just a quick FYI, but I just uploaded a couple of simple ExternalInterface API examples to labs.
The ExternalInterface API allows for player / container communication (such as ActionScript / JavaScript communication).
I plan on uploading some more examples over the next couple of days.
Note, these are built with ActionScript 3 and Flex 2, although the API is available in Flash 8.
You can view the examples here.
You can download the Flex Builder 2 / ActionScript 3 Alphas from here.






Mike , have you noticed that this API does not work in IE, if you put the flash Object inside tags? Still, it works fine in Firefox.
Paulo Azevedo
25 Oct 05 at 11:59 pm
Hi Mike,
Can you include some examples of using this API with a .NET assembly? If you could put up some straight Flash 8 ones too that would be great.
Thanks,
eru
eru
6 Nov 05 at 1:28 am
Hi Mike, great presentation on this at Max. I’ve started building .Net apps using the Flash ActiveX control embedded within a C# app. Many of the apps I build requre irregularly shaped windows — meaning a transparent background.
The problem is that I can’t figure out how to tell the control not to draw the background (you can have flash content with transparent backgrounds when running within HTML. So I’m assuming that browsers that use it have a way to make backgrounds transparent). The “WMode” property doesn’t seem to do the trick for me. Any suggestions?
Scott Williams
18 Nov 05 at 8:58 am
Hi Mike,
I’m using ExternalInterface in Flash 8 and encountered a performance problem. Passing large parameters (a 30-100k string) to ExternalInterface.call takes a really long time (20-100sec) even if no processing occurs on the javascript side.
Any advice, comment or work-around?
Thanks,
Julien Couvreur
28 Dec 05 at 2:17 pm
we are using externalInterface with c#
while we can get messages back and forth, we are having problems when we make a class for the communications
is there a scope issue when you make a class for externalInterface functionality?
it doesnt seem to like to communicate with other objects or raise events
or am i doing something wrong?
dan
4 Jan 06 at 12:05 pm
Hi Mike,
I am having a similar problem to Mesh, in IE the External Interface call is unable to correctly call the given script if the Flash is inside a tag.
The error message is:
[code]
...
Error: '[i]componentName[/i]' is undefined
Code: 0
[/code]
where [i]componentName[/i] is the Flash component name.
Is there any work around (appart from using getURL(“javascript:…”)) ?
Thanks a Lot,
Luis
Luis Bontempo
10 Jan 06 at 10:17 am
Hi Mike,
I am having a similar problem to Mesh, in IE the External Interface call is unable to correctly call the given script if the Flash is inside a tag.
The error message is:
…
Error: ‘componentName’ is undefined
Code: 0
where componentName is the Flash component name.
Is there any work around (appart from using getURL(“javascript:…”)) ?
Thanks a Lot,
Youness
Youness Chraibi
15 Feb 06 at 12:21 pm
here is my workaround for the “movies inside of FORM tags dont work properly” bug. simply include the following javascript BEFORE the flash movies in the HTML. (this code is based on the work by anonym[+] posted in the macromedia livedocs)
<script type=”text/javascript”>
function ExternalInterfaceManager()
{
this.registerMovie = function(movieName) {
if(!window.fakeMovies) window.fakeMovies = new Array();
window.fakeMovies[window.fakeMovies.length] = movieName;
}
this.initialize = function() {
if(document.all)
{
if(window.fakeMovies)
{
for(i=0;i<window.fakeMovies.length;i++)
{
window[window.fakeMovies[i]] = new Object();
}
window.onload = initializeExternalInterface;
}
}
}
}
function initializeExternalInterface()
{
for(i=0;i<window.fakeMovies.length;i++)
{
var movieName = window.fakeMovies[i];
var fakeMovie = window[movieName];
var realMovie = document.getElementById(movieName);
for(var method in fakeMovie)
{
realMovie[method] = function() {flashFunction = “<invoke name=\”" + method.toString() + “\” returntype=\”javascript\”>” + __flash__argumentsToXML(arguments, 0) + “</invoke>”;this.CallFunction(flashFunction);}
}
window[movieName] = realMovie;
}
}
</script>
<script type=”text/javascript”>
var eim = new ExternalInterfaceManager();
eim.registerMovie(“ShockwaveFlash1″);
eim.registerMovie(“ShockwaveFlash2″);
eim.initialize();
</script>
brian dunnington
9 May 06 at 4:59 pm
The workarownd doesn’t work in IE; It works, but with errors
tiberiu
11 Jan 07 at 2:52 pm
Communication between JavaScript and ActionScript fails if a Flash or Flex movie uses ExternalInterface inside a form tag in Internet Explorer.
solution
Add the following script after the embedded Flash movie:
window.[flash_movie_id] = document.forms[0].[flash_movie_id] ;
For example, if your flash_movie_id is called “sample” you would use the following:
window.sample = document.forms[0].sample;
http://kb2.adobe.com/cps/400/kb400730.html
Daveb
2 Oct 09 at 7:24 am