I'm having some strange inter-domain loading behaviour. I need to give my loading swf access to my loaded swf's classes and methods across domains, but despite all my applicationDomain settings and cross domain settings, I'm not being able to cast it to a usable type across domains, but it works perfectly same domain.
The scenario:
Application on domain A loads a skin from domain B (actually all part of a massive domain structure (test.domain.co.uk, assets.domain.co.uk, etc), but for Flash's purposes they are different). Currently some of the files are on a testing environment and will move through several environments before it goes live, so I'm keeping all security calls relatively loose. There are crossdomain.xml files all over the place.
the loading code:
_skinLoader = new Loader();
addChild(_skinLoader);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
_skinLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, skinError, false, 0, true);
_skinLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, skinLoaded);
var skinurl:String = "http://www.domainB/skins/skin.swf";
var request : URLRequest = new URLRequest(skinurl);
_skinLoader.load(request, context);
the COMPLETE event code:
onSkinLoaded(e:Event):void{
addChild(_skinLoader);
_skin = e.currentTarget.content as ISkin;
trace("SHELL: Skin loaded:"+_skin); //======== traces out null when x-domain but traces out[object SkinObject] on the same domain or in the IDE
trace("SHELL: Skin target:"+e.currentTarget.content); //===== traces out [object SkinObject] on both
...............
}
So it works when the skin is on the same domain as the shell application, but not when they are separate. As you may tell from the code above the skin implements ISkin and extends and abstract class ASkin; to deal with security I have the following as the constructor of the skin class (which is the base class of the fla).
public function SkinObject(){
Security.allowDomain(this.root.loaderInfo.loaderURL);
super();
}
Other info:
- Traces in the skin constructor class fire
- When the skin is on the same domain if I test
(e.currentTarget.content is ISkin)
I get true, when on separate domains, I get false - There are no security events
- I have tried setting the loader context to new ApplicationDomain as well.