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.

9 Responses to ExternalInterface API Examples

  1. Paulo Azevedo says:

    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.

  2. eru says:

    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

  3. Scott Williams says:

    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?

  4. 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,

  5. dan says:

    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 communicationsis there a scope issue when you make a class for externalInterface functionality?it doesnt seem to like to communicate with other objects or raise eventsor am i doing something wrong?

  6. Luis Bontempo says:

    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 undefinedCode: 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

  7. Youness Chraibi says:

    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 undefinedCode: 0where componentName is the Flash component name.Is there any work around (appart from using getURL(“javascript:…”)) ?Thanks a Lot,Youness

  8. brian dunnington says:

    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>

  9. tiberiu says:

    The workarownd doesn’t work in IE; It works, but with errors