User Guide

182 Display Programming
securityDomain—Use this property only when loading a SWF file (not an image).
Specify this for a SWF file from a domain other than that of the file containing the Loader
object. When you specify this option, Flash Player checks for the existence of a cross-
domain policy file, and if one exists, SWF files from the domains permitted in the cross-
policy file can cross-script the loaded SWF content. You can specify
flash.system.SecurityDomain.currentDomain as this parameter.
applicationDomain—Use this property only when loading a SWF file written in
ActionScript 3.0 (not an image or a SWF file written in ActionScript 1.0 or 2.0). When
loading the file, you can specify that the file be included in the same application domain
as that of the Loader object, by setting the
applicationDomain parameter to
flash.system.ApplicationDomain.currentDomain. By putting the loaded SWF file in
the same application domain, you can access its classes directly. This can be useful if you
are loading a SWF file that contains embedded media, which you can access via their
associated class names. For more information, see ApplicationDomain class
on page 436.
Here’s an example of checking for a cross-domain policy file when loading a bitmap from
another domain:
var context:LoaderContext = new LoaderContext();
context.checkPolicyFile = true;
var urlReq:URLRequest = new URLRequest("http://www.[your_domain_here].com/
photo11.jpg");
var ldr:Loader = new Loader();
ldr.load(urlReq, context);
Here’s an example of checking for a cross-domain policy file when loading a SWF from
another domain, in order to place the file in the same security sandbox as the Loader object.
Additionally, the code adds the classes in the loaded SWF file to the same application domain
as that of the Loader object:
var context:LoaderContext = new LoaderContext();
context.securityDomain = SecurityDomain.currentDomain;
context.applicationDomain = ApplicationDomain.currentDomain;
var urlReq:URLRequest = new URLRequest("http://www.[your_domain_here].com/
library.swf");
var ldr:Loader = new Loader();
ldr.load(urlReq, context);
For more information, see the LoaderContext class in the ActionScript 3.0 Language Reference.