Note that there are some explanatory texts on larger screens.

plurals
  1. POActionscript's ExternalInterface.addCallback only working locally, not in production
    primarykey
    data
    text
    <p>In my Flex app, I need a Javascript control to call one of my Actionscript methods. Simple enough, according to the Flex/Actionscript documentation, I wrote this in my Actionscript code:</p> <pre><code>if (ExternalInterface.available) ExternalInterface.addCallback("setName", setNameInActiveWindow); </code></pre> <p>In the Javascript control I wrote:</p> <pre><code>document.getElementById('FlexAppId').setName(name); </code></pre> <p>Works great. Exactly as expected, so I went to production. But it doesn't work in production :(. Same exact code... I can't figure it out. The above Javascript code is run, but the callback is not executed in the Actionscript code.</p> <p>Does this have something to do with domain security? Locally, I'm using local.mydomain.com:8080 where local.mydomain.com resolves to 127.0.0.1 (I need to do this so some widgets work properly). And the Flex app comes from the same local webserver. In production, however, it's just www.mydomain.com (mydomain.com is not the real domain name) and the Flex app comes from flash.mydomain.com (a CDN).</p> <p>I have a crossdomain.xml file at www.mydomain.com:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"&gt; &lt;cross-domain-policy&gt; &lt;site-control permitted-cross-domain-policies="master-only"/&gt; &lt;allow-access-from domain="*.mydomain.com"/&gt; &lt;/cross-domain-policy&gt; </code></pre> <p><strong><em>UPDATE</em></strong>: I tried changing the local environment so that the Flex app is referenced from flash.mydomain.com, just like in production. It turns out I get the same problem locally too... so it seems this is some kind of domain security issue despite the crossdomain.xml file I have above. Do I need to change something in my crossdomain.xml? Is there something additional I need to get <code>ExternalInterface.addCallback</code> to work?</p> <p><strong><em>UPDATE 2</em></strong>: Got it to work! I had to do both <code>Security.allowDomain("*")</code> and <code>Security.allowInsecureDomain("*")</code>. Setting it to flash.mydomain.com did NOT fix the issue, I had to put a wildcard. <code>allowNetworking</code> had no effect. I need <code>allowScriptAccess="always"</code>, but I had that from before. Calling Javascript with <code>ExternalInterface.call</code> works easily with just that parameter. But adding a callback with <code>ExternalInterface.addCallback</code> requires the above Security methods with a wildcard.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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