title: AS3 method call from javascript
body: <p>I'm trying to call an AS3 function from Javascript via <code>SWFObject</code> when i try calling i get this error</p>
  
  <p><code>cannot call method 'js_method_to_call' of null</code></p>
  
  <pre><code>import flash.external.ExternalInterface;   
  var test_var = ExternalInterface.addCallback("js_method_to_call", moveto);
  
  function moveto() {
  gotoAndPlay(1,"Scene 2")
  
  }
  </code></pre>
  
  <p>and this is my HTML file where i'm using the SWFobject</p>
  
  <pre><code>&lt;head&gt;
          &lt;script type="text/javascript" src="swfobject.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
              var flashvars = {};
              var params = {};
              var attributes = {};
              attributes.id = "myFlashContent1";
              swfobject.embedSWF("Test_CEO.swf", "containerid", "800", "600", "9.0.0", false, flashvars, params, attributes);
          &lt;/script&gt;
  
          &lt;script type="text/javascript"&gt;
          function fall(){
          alert("calling");
          try{
              var myobject = document.getElementById("containerid");
              myobject.js_method_to_call();
          }
          catch(err) {
              alert(err.message);
          }
  
          }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="containerid"&gt;
              &lt;a href="http://www.adobe.com/go/getflashplayer"&gt;
                  &lt;img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /&gt;
              &lt;/a&gt;
          &lt;/div&gt;
           &lt;input id="save file" type="button" value="clickme" onclick="fall();" /&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Reference : <a href="https://stackoverflow.com/a/7658201/2260496">Link</a></p>