`
tqdo82tqdo
  • 浏览: 14215 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

ApplicationDomain学习

 
阅读更多

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));
  }
  }
  }
分享到:
评论

相关推荐

    applicationDomain学习资料

    applicationDomain学习资料

    基于支持向量机的机器学习研究 Research of Machine-Learning Based Support Vector Machine

    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 ...

    Struts2 学习笔记

    2、 域模型(Domain Model) 10 3、 ModelDriven接收参数 11 十、 Action属性接收参数中文问题 12 十一、 简单数据验证 12 十二、 访问Web元素 14 一、 方法一:ActionContext方式 15 二、 方式二:Ioc(控制反转)—...

    .net EXT学习资料与源码

    .net EXT学习资料与源码 ext是一个强大的js类库,以前是基于YAHOO-UI,现在已经完全独立了,  主要包括data,widget,form,grid,dd,menu,其中最强大的应该算grid了,编程思想是基于面对对象编程(oop),扩展性相当的好.可以...

    Java Web编程宝典-十年典藏版.pdf.part2(共2个)

    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...

    Weblogic基础入门学习系列

    2、Weblogic Domain and Server配置; 3、Weblogic 与 Jbuilder 的整合; 4、Weblogic Server发布第一个Web Application(JSP); 5、Weblogic ConnectionPool的建立; 6、DataSource 与Tx DataSource的区别;

    NewSID(光学习一下代码就可以了,没看清楚介绍别运行)

    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 ...

    中国移动ONENET平台测试项目-基于Springboot+源代码+文档说明

    src/main/resources/application.yml:系统具体配置项文件 src/main/resources/log.xml:系统日志配置 ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目...

    springboot:springboot学习百里香WebSecurityConfigurerAdapter

    springboot springboot learn 在Eclispe中启动 选中DemoApplication.java, run as->...domain对象是quickCD的domain PathVariableDemo result:Hi zhaoqiansunli周吴郑王 result:Add 33, Count:xx http://localhos

    Web服务器安全管理.pptx

    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 ...

    Web服务器安全管理.pptx.pptx

    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,...

    asp.net知识库

    C#静态成员和方法的学习小结 C#中结构与类的区别 C#中 const 和 readonly 的区别 利用自定义属性,定义枚举值的详细文本 Web标准和ASP.NET - 第一部分 XHTML介绍 在ASP.NET页面中推荐使用覆写(Override)而不是事件...

    2018 deep learning applications in biology and medicine.pdf

    Opportunities and obstacles for deep learning in biology and medicine is a nice review about the application of deep learning in the biomedical domain.

    网络安全知识入门.docx

    DNS:DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。DNS协议运行在UDP协议之上,使用端口...

    基于springboot的权限验证+源代码+文档说明

    domain: localhost # 授权域名(必须) exclude: true # 账户令牌排他性,true 表示一个账号只会保留最后一次生成的令牌;false 表示一个账号可以对应多个令牌(非必须,默认 false) cacheInitialCapacity: 100 ...

    Outlier Analysis

    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...

    网络安全知识(1).doc

    DNS:DNS(Domain Name System,域名系统),因特网上作为域名和IP地址相互映射的一个分布式数据库,能够 使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串。DNS协议运行 在UDP协议之上,使用...

    基于java开发的开源网址导航网站项目源码+数据库+项目说明.zip

    3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 4、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于java...

    An Introduction to Deep Learning for the Physical Layer

    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 ...

Global site tag (gtag.js) - Google Analytics