7 Replies Latest reply on Jul 16, 2010 12:04 PM by kglad

    Working ExternalInterface Example

    jimt899

      Hi,

       

      I've been struggling to get a simple ExternalInterface example working for the past few hours. Adobe docs, online examples, etc., and absolutely nothing works. Perhaps someone can help me figure out where I'm going wrong. In its most simple form:

       

      Actionscript 3 code:

       

      public class Test

      {

       

        public function Test()

        {

          ExternalInterface.addCallback("callActionscript", callActionscriptMethod);

        }

       

        public function callActionscriptMethod():void

        {

          ExternalInterface.call("alert", "Method called");

        }

      }

       

      After I publish this file, I edit the generated html file and add the following Javascript.

       

      function getFlashMovie(movieName)

        var isIE = navigator.appName.indexOf("Microsoft") != -1; 

        return (isIE) ? window[movieName] : document[movieName];

       

      function testCall()

        getFlashMovie("Test").callActionscript();

       

      In Chrome, I get something along these lines when I try to call 'testCall();':

       

      TypeError: Object #<an HTMLEmbedElement> has no method 'testCall'

       

      Can anyone help me debug this?