title: Calling a function in ActionScript 3.0/Flash from JavaScript using ExternalInterface
body: <p>I can't get this to work even after making sure to set "allowScriptAccess" to always. I successfully put the flash movie in the browser and call ReceiveDataFromFlashMovie() and print "Got here" but it seems like GetFlashMovieObject() only returns NULL according to an error message in Internet Explorer. Am I missing something?</p>
  
  <p>Head of the HTML file:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function getFlashMovieObject(movieName)
  {
    if (navigator.appName.indexOf("Microsoft") != -1) { 
      return window[movieName] 
    } 
    else { return document[movieName] }
  }
  
  function ReceiveDataFromFlashMovie()
  {
       document.write("Got here");
       var callResult = getFlashMovieObject("MakingButtons").myFunction();
       return callResult;
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  document.write("Hello World.")
  ReceiveDataFromFlashMovie();
  document.write(callResult)
  &lt;/script&gt;
  
  &lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="500" height="500" id="MakingButtons" align="middle"&gt;
  &lt;param name="allowScriptAccess" value="always" /&gt;
  &lt;param name="movie" value="MakingButtons.swf" /&gt;
  &lt;param name="quality" value="high" /&gt;
  &lt;param name="bgcolor" value="#ffffff" /&gt;
  &lt;embed src="MakingButtons.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="MakingButtons" align="middle" allowScriptAccess="always" swlliveconnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /&gt;
  &lt;/object&gt;
  </code></pre>
  
  <p>ActionScript 3.0:</p>
  
  <pre><code>import flash.text.TextField;
  import flash.external.*;
  // The name of the Flash variable to be called in JavaScript
  var flashFunction:String = "myFunction";
  var instance:Object = null;
  
  // Callback function executed by the name of variable
  var realFunction:Function = callMe;
  ExternalInterface.addCallback(flashFunction, realFunction);
  
  var foo = "Goodbye!";
  function callMe():String
  {
      return foo;
  }
  </code></pre>
  
  <p>Thank you!</p>