Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem accessing ExternalInterface exposed method in Google Chrome
    text
    copied!<p>My simple ActionScript I am trying to use Flash's <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html" rel="nofollow noreferrer">ExternalInterface</a> to setup a callback so that JavaScript can call a method on my Flash object. Everything works fine in Safari, Firefox and in IE, but I cannot get Chrome working. When I try the code on Chrome, I get the following error: </p> <blockquote> <p>Uncaught TypeError: Object #&lt;an HTMLObjectElement&gt; has no method 'setText'</p> </blockquote> <p>Here is the example HTML I am using (again, works fine in Safari, FF and IE)</p> <pre><code>&lt;html&gt;&lt;body&gt; &lt;div id="mycontent"&gt;&lt;/div&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; swfobject.embedSWF("http://invincible.dynalias.com:8080/HelloWorld.swf", "mycontent", "400", "420", "9.0.0","expressInstall.swf", {}, {allowScriptAccess:'always'},{id:'hw',name:'hw'}); function getFlash(movieName) { return ( navigator.appName.indexOf("Microsoft") != -1) ? window[movieName] : document.getElementById(movieName); } &lt;/script&gt;&lt;p&gt; &lt;input type="text" id="exampleText" /&gt; &lt;input type="button" value="Set Text" onclick="getFlash('hw').setText(document.getElementById('exampleText') .value)" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and here is the ActionScript...</p> <pre><code>package { import flash.display.Sprite; import flash.text.TextField; import flash.external.ExternalInterface; import flash.system.Security; public class HelloWorld extends Sprite { private var textField:TextField = new TextField(); public function HelloWorld() { Security.allowDomain("*"); ExternalInterface.addCallback("setText", this.setText); textField.text = "Hello, world!"; addChild(textField); } public function setText(text:String):void { this.textField.text = text; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload