According to Adobe's documentation (Loader#securityDomain):
In order for import loading to succeed, the loaded SWF file's server
must have a policy file trusting the domain of the loading SWF file.
The trick is telling Loader to check the crossdomain file when loading the swf, by passing true
as the first parameter when creating the LoaderContext
, eg:
var request:URLRequest = new URLRequest(_file.url);
var context:LoaderContext = new LoaderContext(true, null, SecurityDomain.currentDomain);
var loader:Loader = new Loader();
loader.load(request, context);
The accompanying cross-domain.xml should be located in the same location as the child SWF, or in one of its parent folders. Here's a non-restrictive cross-domain file according to documentation from Adobe:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" secure="false"/>
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
</cross-domain-policy>
One other thing that might make this easier for you, is to pass the interface instead of the class, which would effectively bypass conflicting code. This will work because the child inherits the interface from the parent class by default at runtime (see Loader#applicationDomain point #1). The child class can then safely instance it's own version of each object as long as that object adheres to the interface. For example:
var applicationDomain:ApplicationDomain = loader.contextLoaderInfo.applicationDomain;
var classDefinition:Class = applicationDomain.getDefinition("MyBigAwesomeClass") as class;
var instance:IMyBigAwesomeInterface = new classDefinition() as IMyByAwesomeInterface;
The definition for MyBigAwesomeClass would then look something like this:
public class MyBigAwesomeClass implements IMyBigAwesomeInterface
{
...
}