ActionScript 3 加载器上下文

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 加载器上下文相关的知识,希望对你有一定的参考价值。

/*
When loading an SWF into another SWF you have 3 options for the placement of the loaded SWFs definitions:

    * new partitioned domain: create a new separated domain for the loaded SWFs definitions to live that will separate it completely from those definitions within the loading SWF.
    * current domain: load the definitions into the current application domain of the loading SWF. This will not overwrite existing definitions but it will add new definitions to those within the current application domain of the SWF doing the loading.
    * child domain (default): load the definitions into a new application domain that is a child of the application domain of the loading SWF. This will not affect the current application domain of the loading SWF but it will force the loaded SWF to use any duplicate definitions in the parent over its own


You specify application domains for loaded content within a LoaderContext (flash.system.LoaderContext) instance. This instance is then passed to the load() method of Loader (Loader.load()). For the domain of the current SWF, you can use ApplicationDomain.currentDomain ().

*/

// child SWF uses parent domain definitions
// if defined there, otherwise its own
var childDefinitions:LoaderContext = new LoaderContext();
childDefinitions.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);

// child SWF adds its unique definitions to
// parent SWF; both SWFs share the same domain
// child SWFs definitions do not overwrite parents
var addedDefinitions:LoaderContext = new LoaderContext();
addedDefinitions.applicationDomain = ApplicationDomain.currentDomain;

// child SWF domain is completely separate and
// each SWF uses its own definitions
var separateDefinitions:LoaderContext = new LoaderContext();
separateDefinitions.applicationDomain = new ApplicationDomain();

// set loader context in load()
myLoader.load(request, separateDefinitions);


var NewClass:Class = ApplicationDomain.currentDomain.getDefinition( "myClass" ) as Class;
var newClassInstance:* = new NewClass();

以上是关于ActionScript 3 加载器上下文的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 带缓存的简单加载管理器

ActionScript 3 基本的外部XML加载器

ActionScript 3 AS3预加载器

ActionScript 3 PHP加载器

ActionScript 3 xml加载器类

ActionScript 3 AS3:预加载器