ApplicationDomain学习
2011年03月11日
flash.system 包下 final类 继承自Object
ApplicationDomain类是分散的类定义组的一个容器。应用程序域用于划分位于同一个安全域中的类。它们允许同一个类存在多个定义,并且允许子级重用父级定义。
在通过Loader类加载外部SWF文件时会使用应用程序域。加载的SWF文件中的所有Actionscript 3.0定义都存储在由LoaderContext对象的applicationDomain属性指定的应用程序域中,此对象是您为Loader对象的load()()或loadBytes()方法传递的context参数。LoaderInfo对象还包含一个只读的applicationDomain属性。
SWF文件中的所有代码被定义为存在于应用程序域中。主应用程序就在当前的应用程序域中运行。系统域中包含所有应用程序域(包括当前域),这意味着它包含所有Flash Player类。
除系统域以外,每个应用程序域都有一个关联的父域。主应用程序的应用程序域的父域是系统域。已加载的类仅在其父级中没有相关定义时才进行定义。不能用较新的定义覆盖已加载的类定义。
公共属性
currentDomain : ApplicationDomain 【静态】【只读(read-only)】
获取正在其中执行代码的当前应用程序域。
domainMemory : ByteArray
获取并设置将在此ApplicationDomain中对其执行域全局内存操作的对象。
MIN_DOMAIN_MEMORY_LENGTH : uint [静态][只读]
获取用作ApplicationDomain.domainMemory所需的最小内存对象长度。
parentDomain : ApplicationDomain [只读]
获取该应用程序域的父域。
公共方法
ApplicationDomain(parentDomain : ApplicationDomain = null)
创建一个新的应用程序域
参数:
parentDomain :ApplicationDomain(default = null)
如果未传入父域,此应用程序域将使用系统域作为其父域。
getDefinition(name : String) : Object
从指定的应用程序域获取一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。
参数:
name :String 定义的名称
返回:
Object :与此定义关联的对象。
引发:
ReferenceError :不存在具有指定名称的公共定义。
hasDefinition(name : String) : Boolean
检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。
参数:
name :String 定义的名称
返回:
Boolean :如果指定的定义存在,则返回true,否则,返回false
演示:加载运行时的类,调用位于另一个 SWF 中的类的公共方法。
注意:1.由于ClassLoader类要加载SWF文件,因此需要文件系统级别的本地安全性。
2.若要运行此示例,在ApplicationDomainExample.swf文件所在的文件夹中必须存在一个名为RuntimeClasses.swf的SWF文件。
首先,使用下面的代码创建RuntimeClasses.swf的SWF文件。
package ApplicationDomainTest
{
import flash.display.Sprite;
public class RuntimeClasses extends Sprite
{
public function RuntimeClasses()
{
}
public function greet() : String
{
return ("Hello World");
}
}
}
package ApplicationDomainTest
{
import flash.display.Sprite;
import flash.errors.IllegalOperationError;
import flash.events.Event;
import flash.text.TextField;
public class ApplicationDomainExample extends Sprite
{
private var loader : ClassLoader;
private var tf : TextField = new TextField();
public function ApplicationDomainExample()
{
addChild(tf);
tf.text = "I am a textfield";
loader = new ClassLoader();
loader.addEventListener(ClassLoader.LOAD_ERROR, loadErrorHandler);
loader.addEventListener(ClassLoader.CLASS_LOADED, classLoadedHandler);
loader.load("RuntimeClasses.swf");
}
private function loadErrorHandler(e : Event) : void
{
tf.text = "Load failed";
throw new IllegalOperationError("Cannot load the specified file.");
}
private function classLoadedHandler(e : Event) : void
{
var runtimeClassRef : Class = loader.getClass("RuntimeClasses");
var greeter : Object = new runtimeClassRef();
tf.text = greeter.greet();
}
}
}
package ApplicationDomainTest
{
import flash.display.Loader;
import flash.errors.IllegalOperationError;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
public class ClassLoader extends EventDispatcher
{
public static var CLASS_LOADED : String = "classLoaded";
public static var LOAD_ERROR : String = "loadError";
private var loader : Loader;
private var swfLib : String;
private var request : URLRequest;
private var loadedClass : Class;
public function ClassLoader()
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler);
loader.contentLoaderInfo.addEventListener(IOErrorE vent.IO_ERROR, ioErrorHandler);
loader.contentLoaderInfo.addEventListener(Security ErrorEvent.SECURITY_ERROR, securityErrorHandler);
}
public function load(lib : String) : void
{
swfLib = lib;
request = new URLRequest(swfLib);
var context : LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
loader.load(request, context);
}
public function getClass(className : String) : Class
{
try{
return loader.contentLoaderInfo.applicationDomain.getDefi nition(className) as Class;
}
catch(e : Error)
{
throw new IllegalOperationError(className + " definition not found in " + swfLib);
}
return null;
}
private function completeHandler(e : Event) : void
{
dispatchEvent(new Event(ClassLoader.CLASS_LOADED));
}
private function ioErrorHandler(e : Event) : void
{
dispatchEvent(new Event(ClassLoader.LOAD_ERROR));
}
private function securityErrorHandler(e : Event) : void
{
dispatchEvent(new Event(ClassLoader.LOAD_ERROR));
}
}
}
发表评论
-
windows mobile activex and atl create (from csdn)
2012-01-20 09:25 604windows mobile activex and atl ... -
以远程桌面访问Windows Azure虚拟机(转+译)
2012-01-20 09:25 836以远程桌面访问Windows Az ... -
myeclipse 配置android SDK 出现 could not find adb.exe 和 tools 找不到的问题
2012-01-20 09:25 795myeclipse 配置android SDK 出现 coul ... -
更新:来自MIX11的Windows Azure新闻
2012-01-20 09:25 601更新:来自MIX11的Windows Az ... -
Android环境配置与HelloWorld程序(Windows)
2012-01-20 09:25 641Android环境配置与HelloWorl ... -
那些年,那些人,那些事
2012-01-19 14:26 500那些年,那些人,那些事 2012年01月14日 ... -
jjk
2012-01-19 14:26 582jjk 2011年12月25日 ... -
端午节的历史与风俗详考
2012-01-19 14:26 596端午节的历史与风俗详考 2010年06月13日 [摘要] ... -
明史 卷四十七??志第二十三
2012-01-19 14:26 530明史 卷四十七??志第二十三 2011年04月29日 礼 ... -
2011-7-3
2012-01-19 14:26 5432011-7-3 2011年07月03日 电大《汉语基础 ... -
ActionScript3: Dynamic Class
2012-01-17 04:14 609ActionScript3: Dynamic Class 2 ... -
ReferenceError: Error #1069
2012-01-17 04:14 626ReferenceError: Error #1069 20 ... -
【转】 JavaScript 异常 使用throw语句抛出异常顾名思义,就是超出常规,
2012-01-17 04:14 699【转】 JavaScript 异常 使 ... -
2011年9月9日
2012-01-17 04:14 4662011年9月9日 2011年01月15日 重要提醒:系 ... -
赞美女人的词语
2012-01-16 03:04 684赞美女人的词语 2011年02月24日 形容美貌: ... -
赞美客户词汇大全
2012-01-16 03:04 824赞美客户词汇大全 2009 ... -
赞美客户词汇大全
2012-01-16 03:04 808赞美客户词汇大全 2011 ... -
词语的感情色彩
2012-01-16 03:03 1370词语的感情色彩 2009年1 ... -
形容女人漂亮的词语、成语或诗句
2012-01-16 03:03 1291形容女人漂亮的词语、成语或诗句 2010年11月29日 ...
相关推荐
applicationDomain学习资料
This article summarize today state and application domain of machine-learning and Support Vector Machine,expound basic concept and basic model of machine-learning and Support Vector Machine and ...
2、 域模型(Domain Model) 10 3、 ModelDriven接收参数 11 十、 Action属性接收参数中文问题 12 十一、 简单数据验证 12 十二、 访问Web元素 14 一、 方法一:ActionContext方式 15 二、 方式二:Ioc(控制反转)—...
.net EXT学习资料与源码 ext是一个强大的js类库,以前是基于YAHOO-UI,现在已经完全独立了, 主要包括data,widget,form,grid,dd,menu,其中最强大的应该算grid了,编程思想是基于面对对象编程(oop),扩展性相当的好.可以...
86.2 域模型DomainModel 86.3 驱动模型ModelDriven 8.7 实战检验 8.7.1 Struts2处理表单数据 8.7.2 使用M印类型的request、session、application 8.8 疑难解惑 8.8.1 Struts Prepare And Execute Filter过滤器 8.8.2...
2、Weblogic Domain and Server配置; 3、Weblogic 与 Jbuilder 的整合; 4、Weblogic Server发布第一个Web Application(JSP); 5、Weblogic ConnectionPool的建立; 6、DataSource 与Tx DataSource的区别;
This tool requires that the system administrator perform a full install (usually a scripted unattended installation) on each computer, and then sysdiff automates the application of add-on software ...
src/main/resources/application.yml:系统具体配置项文件 src/main/resources/log.xml:系统日志配置 ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目...
springboot springboot learn 在Eclispe中启动 选中DemoApplication.java, run as->...domain对象是quickCD的domain PathVariableDemo result:Hi zhaoqiansunli周吴郑王 result:Add 33, Count:xx http://localhos
etc.) ISAPI Filters Application Pool 2 W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain ...
etc.) ISAPI Filters Application Pool 2 W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain W3WP.EXE ASP.NET ISAPI CLR App Domain CLR App Domain ...
An application of a mastery learning strategy 130 FELIX MARTIN REFERENCES ASCHNER, M. J. Asking questions to trigger thinking. National Education Association Journal, 1961, 60, 44-46. ASCHNER,...
C#静态成员和方法的学习小结 C#中结构与类的区别 C#中 const 和 readonly 的区别 利用自定义属性,定义枚举值的详细文本 Web标准和ASP.NET - 第一部分 XHTML介绍 在ASP.NET页面中推荐使用覆写(Override)而不是事件...
Opportunities and obstacles for deep learning in biology and medicine is a nice review about the application of deep learning in the biomedical domain.
DNS:DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。DNS协议运行在UDP协议之上,使用端口...
domain: localhost # 授权域名(必须) exclude: true # 账户令牌排他性,true 表示一个账号只会保留最后一次生成的令牌;false 表示一个账号可以对应多个令牌(非必须,默认 false) cacheInitialCapacity: 100 ...
in any application scenario. As a result, there has been a tremendous need to design methods and algorithms which can effectively process a wide variety of text applications. This book will provide an...
DNS:DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够 使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。DNS协议运行 在UDP协议之上,使用...
3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 4、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于java...
Lastly, we demonstrate the application of convolutional neural networks on raw IQ samples for mod- ulation classification which achieves competitive accuracy with respect to traditional schemes ...