AS3 and cross-domain

Posted by Davide Arcinotti on Stack Overflow See other posts from Stack Overflow or by Davide Arcinotti
Published on 2011-11-15T14:08:38Z Indexed on 2011/11/16 1:50 UTC
Read the original article Hit count: 124

Filed under:

I think i'm a little confused. I'm loading an swf, located at domainB.com/secondsubfolder, from an swf located at domainA.com/firstsubfolder.

I always put the crossdomain.xml near the "loader" swf in domainA.com/firstsubfolder.

It seems to not work, except if I put the crossdomain.xml in the root of the loaded content, domainB.com/crossdomain.xml.

Did I always do it wrong, or is it because of some server setting? Using another domain for the loaded content, e.g. domainB_beta.com/secondsubfolder on another server just works as usual.

Where do I have to look to change these settings? Does it depend on server settings, or am I doing something wrong?

This is the loader actionscript code:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.system.Security;

Security.allowDomain("domainB.com"); 
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;

var loaderMain:Loader = new Loader();
loaderMain.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loaderMain.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
loaderMain.load(new URLRequest('domainB/secondsubfolder/file.swf'),context);
addChild(loaderMain);

function errorHandler(event:ErrorEvent):void {
trace("errorHandler says: " + event);

}

© Stack Overflow or respective owner

Related posts about actionscript-3