In Chapter 28, we'll see
how a parent .swf file can load a
child .swf file in a special way
that lets the parent use the child's classes directly, as though they
were defined by the parent. The technique requires that the parent
.swf file import the child
.swf file's classes into its
application domain. Here's the basic code
required in the parent .swf file
(notice the use of the LoaderContext class's instance variable
var loaderContext:LoaderContext = new LoaderContext(); loaderContext.applicationDomain = ApplicationDomain.currentDomain; var loader:Loader = new Loader(); loader.load(new URLRequest("
When the preceding code runs, the attempt to import the child's classes into the parent's application domain will be blocked by Flash Player's security system in the following situations:
If the parent .swf file and the child .swf file are loaded from different remote regions in the remote realm
If the parent .swf file is loaded from the local realm and has a different security-sandbox-type than the child .swf file
In the first of the preceding cases, the distributor of the child .swf file can use a policy file to give the parent .swf file permission to import the child .swf file's classes. The steps required by the child .swf file's distributor and the parent .swf file's creator are as follows:
The child .swf file's distributor must post a policy file authorizing the parent .swf file's origin, as shown in the earlier section, ...