<p>I have a Flex swf hosted at <a href="http://www.a.com/a.swf" rel="nofollow noreferrer">http://www.a.com/a.swf</a>.
I have a flash code on another doamin that tries loading the SWF:</p>

<pre><code>_loader = new Loader();
var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf");
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish);
_loader.load(req);
</code></pre>

<p>On the onLoaderFinish event I try to load classes from the remote SWF and create them:</p>

<pre><code>_loader.contentLoaderInfo.applicationDomain.getDefinition("someClassName") as Class
</code></pre>

<p>When this code runs I get the following exception</p>

<pre><code>SecurityError: Error #2119: Security sandbox violation: caller http://localhost.service:1234/flashTest/Main.swf cannot access LoaderInfo.applicationDomain owned by http://www.b.com/b.swf.
    at flash.display::LoaderInfo/get applicationDomain()
    at NuconomyLoader/onLoaderFinish()
</code></pre>

<p>Is there any way to get this code working?</p>

[{'answer_id': 14384, 'author': 'Rytmis', 'author_id': 266, 'author_profile': 'https://Stackoverflow.com/users/266', 'pm_score': 0, 'selected': False, 'text': '<p>Mayhaps <a href="http://livedocs.adobe.com/flex/15/flex_docs_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flex_Documentation&amp;file=00001750.htm" rel="nofollow noreferrer" title="Flex Documentation: System.Security.allowDomain">System.Security.allowDomain</a> is what you need?</p>\n'}, {'answer_id': 14404, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 4, 'selected': True, 'text': '<p>This is all described in <a href="http://livedocs.adobe.com/flex/3/progAS_flex3.pdf" rel="nofollow noreferrer">The Adobe Flex 3 Programming ActionScript 3 PDF</a> on page 550 (Chapter 27: Flash Player Security / Cross-scripting):</p>\n\n<blockquote>\n  <p>If two SWF files written with ActionScript 3.0 are served from different domains—for example, <a href="http://siteA.com/swfA.swf" rel="nofollow noreferrer">http://siteA.com/swfA.swf</a> and <a href="http://siteB.com/swfB.swf" rel="nofollow noreferrer">http://siteB.com/swfB.swf</a>—then, by default, Flash Player does not allow swfA.swf to script swfB.swf, nor swfB.swf to script swfA.swf. A SWF file gives permission to SWF files from other domains by calling Security.allowDomain(). By calling Security.allowDomain("siteA.com"), swfB.swf gives SWF files from siteA.com permission to script it.</p>\n</blockquote>\n\n<p>It goes on in some more detail, with diagrams and all.</p>\n'}, {'answer_id': 14409, 'author': 'grapefrukt', 'author_id': 914, 'author_profile': 'https://Stackoverflow.com/users/914', 'pm_score': 2, 'selected': False, 'text': '<p>You\'ll need a crossdomain.xml policy file on the server that has the file you load, it should look a something like this:</p>\n\n<pre><code>&lt;?xml version="1.0"?&gt;\n&lt;!-- http://www.foo.com/crossdomain.xml --&gt;\n&lt;cross-domain-policy&gt;\n  &lt;allow-access-from domain="www.friendOfFoo.com" /&gt;\n  &lt;allow-access-from domain="*.foo.com" /&gt;\n  &lt;allow-access-from domain="105.216.0.40" /&gt;\n&lt;/cross-domain-policy&gt;\n</code></pre>\n\n<p>Put it as crossdomain.xml in the root of the domain you\'re loading from.</p>\n\n<p>Also you need to set the loader to read this file as such:</p>\n\n<pre><code>var loaderContext:LoaderContext = new LoaderContext();\nloaderContext.checkPolicyFile = true;\n\nvar loader:Loader = new Loader();\nloader.contentLoaderInfo.addEventListener( Event.COMPLETE, onComplete );\nloader.load( new URLRequest( "http://my.domain.com/image.png" ), loaderContext );\n</code></pre>\n\n<p>code sample yoinked from <a href="http://blog.log2e.com/2008/08/15/when-a-cross-domain-policy-file-is-not-enough/" rel="nofollow noreferrer">http://blog.log2e.com/2008/08/15/when-a-cross-domain-policy-file-is-not-enough/</a></p>\n'}]
['https://Stackoverflow.com/questions/14350', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1228206/']