1 Reply Latest reply: Apr 12, 2012 6:53 AM by kglad RSS

    ExternalInterface In ActionScript 2.0

    Lathika Sreejith

      Hi EveryOne, I am trying to use ExternalInterface Class to provide communication between actionscript 2.0


      and JavaScript. But I am not able to achieve that.


      Following is the code that i used.


      Code in FlaFile.fla is as follows:


      import flash.external.*;


      flash.external.ExternalInterface.addCallback("fnGetVar", fnGetVar);

      function fnGetVar(nn: String ):String {

          nn = "100";

          return ("hai");




      with (mc)


                  beginFill (0xFFFFFF);

                  lineStyle(4, 0x0000FF, 100);

                  moveTo( 0, 0);

                  lineTo (0, 0);

                  lineTo (0, 20);

                  lineTo (20, 20);

                  lineTo (20, 0);

                  endFill ();




      Code in FlaFile.html is as follows:


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-



      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


      function fnCall()




          //var flashMovie = window.document.FlaFile;


          var newVar=FlaFile.fnGetVar("value");











      <body bgcolor="#ffffff">

      <!--url's used in the movie-->

      <!--text used in the movie-->

      <input type="button" value="click!!!" onclick="fnCall()">

      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"




      width="550" height="400" id="FlaFile" name="FlaFile" align="middle">

      <param name="allowScriptAccess" value="always" />

      <param name="movie" value="FlaFile.swf" />

      <param name="quality" value="high" />

      <param name="bgcolor" value="#ffffff" />

      <embed src="FlaFile.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlaFile"


      id="FlaFile" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"


      pluginspage="http://www.macromedia.com/go/getflashplayer" />






      Can Somebody tell me where it is going wrong?


      The error which i am getting in IE9 is "Object doesn't support property or method 'fnGetVar'" and the


      error which i am getting in Chrome is "Object #<HTMLCollection> has no method 'fnGetVar'" and in firefox


      the error is "FlaFile is not defined"


      fla Editor which i am using is Macromedia Flash MX Professional 2004 Version 7.0