0 Replies Latest reply on Jun 20, 2007 9:17 AM by ru_cimic

    ExternalInterface.addCallback Javascript Problem

    ru_cimic
      Here's the code that I tried, but javascript gives an error in both IE and Netscape. (The name of the swf is TestInt1.)

      Actionscript:

      function setTestText(newText:String): void
      {
      testText.text = newText;
      }

      function initApp():void
      {
      ExternalInterface.addCallback("setText", setTestText);
      }


      javascript/html:

      <script language="javascript">
      document.write("<object id='TestInt1' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase=' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' height='100%' width='100%'>");
      document.write("<param name='src' value='./TestInt1.swf'/>");
      document.write("<embed name='TestInt1' src='./TestInt1.swf' pluginspage=' http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' height='100%' width='100%'/>");
      document.write("</object>");


      </script>
      <noscript>
      <object id="TestInt1"
      codebase=' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'
      height='100%' width='100%'>
      <param name="src" value="./TestInt1.swf"/>
      <embed name="TestInt1"
      pluginspage=' http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'
      src='./TestInt1.swf' height='100%' width='100%'>
      </object>
      </noscript>
      <script language="Javascript">

      function thisMovie(movieName) {
      if (navigator.appName.indexOf("Microsoft") != -1) {
      return window[movieName];
      } else {
      return document[movieName];
      }
      }
      function sendToActionScript(value) {
      //thisMovie("TestInt1").setText(value);
      var flashHandle = document.getElementById("TestInt1");
      flashHandle.setText(value);
      }

      sendToActionScript("External Text Display!");

      </script>