Runtime loaded asset seems to have no definition

Hi,

one of you forum readers might get the title for “AS-Guru of all time” pointing me the solution to THIS:

I’m publishing an SWF file on domainA and loading every graphical assets and included classes from another SWF located on domainB.
It’s great.
Locally.

I mean that when the two files are loaded locally side by side, everything rolls fine.
As soon as I’m trying to load the assets library from domainB, I get a runtime error #1009 (null object reference).

The following “crossdomain.xml” is hosted on domainB :

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*" />
    <allow-access-from domain="localhost" />
    <allow-access-from domain="127.0.0.1" />
</cross-domain-policy>

but doesn’t seems to accept remote serving of an SWF from another.
I worked my way around security issues by declaring in the first frame of the library SWF

Security.allowDomain("*");

(now that’s security…)
and the library assets gets loaded fine from domainB, like this:

var path:URLRequest = new URLRequest(Config.SERVER_PATH + "assets/assets.swf");
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onAssetsLoadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(path, context);

Or do they?

The classes associated with the linked library assets gets loaded fine too, as I can instantiate them.
The thing is every time there’s a sub-clip inside one of them, it doesn’t seem to get defined at all.
For instance, I have SimpleButton called “replay_btn” inside a movieClip linked with “OptionsButtons” class.
I have this

public var replay_btn:SimpleButton;

in the class definition.

I repeat : this is working fine when

Config.SERVER_PATH = ""

not anymore when

Config.SERVER_PATH = "domainB"

Winners might get recognition.
A whole lot’of’it.

I know many chicks.
Please help.

Bump.

Still have no solution for that problem.
I triple-checked Security allowance for children and parent, no luck.
It just seems to be forbidden to manually add an MC to another one’s stage when this last one is linked to a class, and then load this to another swf and be able to use the classes without bumping in a null reference to children MCs.

Weird…

Any help would still be very appreciated.

Ok boys, hear this.
If anyone would like to be able to access classes and sub-clips from a swf on another domain than the one accessing it, try this :

var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);

The third argument (securityDomain) set to SecurityDomain.currentDomain visibly changed the way assets gets added to application sandbox.
Not sure about the voodoo behind it but that’s the way to go.

Hope this help someone.
Cheers.