I have a Flex swf hosted at http://www.a.com/a.swf. I have a flash code on another doamin that tries loading the SWF:
_loader = new Loader();
var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf");
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish);
_loader.load(req);
On the onLoaderFinish event I try to load classes from the remote SWF and create them:
_loader.contentLoaderInfo.applicationDomain.getDefinition("someClassName") as Class
When this code runs I get the following exception
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()
Is there any way to get this code working?
Mayhaps System.Security.allowDomain is what you need?
This is all described in The Adobe Flex 3 Programming ActionScript 3 PDF on page 550 (Chapter 27: Flash Player Security / Cross-scripting):
It goes on in some more detail, with diagrams and all.
You'll need a crossdomain.xml policy file on the server that has the file you load, it should look a something like this:
Put it as crossdomain.xml in the root of the domain you're loading from.
Also you need to set the loader to read this file as such:
code sample yoinked from http://blog.log2e.com/2008/08/15/when-a-cross-domain-policy-file-is-not-enough/