title: Calling Flash function using ExternalInterface
body: <p>I'm having trouble calling a function through the use of ExternalInterface.</p>
  
  <p>First off, here's the HTML/JS side:</p>
  
  <pre><code>&lt;p align="right"&gt;
  &lt;object type="application/x-shockwave-flash" data="camera.swf" 
  width="200" height="200" align="right" id="camSWF"&gt;
  &lt;param name="movie" value="camera.swf" align="right" /&gt;
  &lt;param name="allowScriptAccess" value="always" /&gt;
  &lt;/object&gt;&lt;/p&gt;
  &lt;script type="text/javascript"&gt;
  var flashObj = document.getElementById('camSWF');
  document.onmousemove = setMouseXY;
  function setMouseXY(e) {
      var x = e.pageX;
      var y = e.pageY;
      flashObj.rotateCam(x, y, $(document).width(), $(document).height());
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And secondly, here is the ActionScript 2 code:</p>
  
  <pre><code>ExternalInterface.addCallback('setMouseXY', null, rotateCam);
  function rotateCam(mouseX, mouseY, docWidth, docHeight)
  {
      // DO STUFF
  }
  </code></pre>
  
  <p>As far as I can see, everything should work, but obviously I'm missing something.</p>
  
  <p>Whenever the mouse event fires on the HTML page, I get this error in Firebug:</p>
  
  <pre><code>flashObj.rotateCam is not a function: 
  flashObj.rotateCam(x, y, $(document).width(), $(document).height());
  </code></pre>
  
  <p>I'm quite stuck. Perhaps it's some security thing?</p>