云下的天空

坚持 随心而动 走自己的路

 

AS中的Parent,ParentDocument,ParentApplication属性


原文链接:

http://blog.shinysky.com/2010/02/as-parent-parentdocument-parentapplication/


Flex中的组件(Component)有三个属性, 通常用来引用上级的对象, 它们是 Parent, ParentDocument, ParentApplication.

1. Parent:指包含此组件的父级容器对象(DisplayObjectContainer), 这里的包含是词义上(Lexical)的包含. DisplayObjectContainer是一个抽象类, 是所有能够包含子对象(child objects)的父类.

The DisplayObjectContainer class is an abstract base class for all objects that can contain child objects. It cannot be instantiated directly; calling the new DisplayObjectContainer() constructor throws an ArgumentError exception.

Inheritance: UIComponent-> FlexSprite-> Sprite-> DisplayObjectContainer-> InteractiveObject-> DisplayObject-> EventDispatcher-> Object



2. ParentDocument:指向包含此组件的父文档对象. 这里关键点是 什么是文档对象? 文档对象是顶层的Flex程序, MXML组件或者AS组件, 其类型必须是UIComponent, 所以, Document一般指代的是自定义组件的根结点或者程序的Application结点. 它和Parent的区别是在于, 它不是词义上的父对象, 而是父文档. 例如我们自定义一个继承Panel的MXML组件, FormItem的Parent是Form, 而FormItem 和Form 的ParentDocument则都是Panel.

1<s:Panel>
2  <mx:Form width="100%" height="100%">
3    <mx:FormItem />
4  </mx:Form>
5</s:Panel>

A reference to the parent document object for this UIComponent. A document object is a UIComponent at the top of the hierarchy of a Flex application, MXML component, or AS component. For the Application object, the parentDocument property is null. This property is useful in MXML scripts to go up a level in the chain of document objects. It can be used to walk this chain using parentDocument.parentDocument, and so on. It is typed as Object so that authors can access properties and methods on ancestor document objects without casting.



3. ParentApplication:指向包含此组件的 Application 对象. 通常一个Flex程序包含在标签中, 但这个程序又可能会作为一个模块(moduler)存在于更大的程序中. ParentApplication则指向了包含此组件的”最近”的Application 对象, 当存在更上一层的Application 对象时, 可以通过ParentApplication.ParentApplication这样的链接来存取.

A reference to the Application object that contains this UIComponent instance. This Application object might exist in a SWFLoader control in another Application, and so on, creating a chain of Application objects that can be walked using parentApplication. The parentApplication property of an Application is never itself; it is either the Application into which it was loaded or null (for the top-level Application).

posted on 2011-06-04 11:07 天空布蓝 阅读(2581) 评论(0)  编辑  收藏 所属分类: Flex4


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔分类

随笔档案

Flex学习链接

搜索

最新评论

  • 1. re: tomcat7的配置
  • 新建变量名: TOMCAT_HOME 应该为CATALINA_HOME
  • --houkai
  • 2. re: tomcat7的配置
  • 确实是的@寒澈
  • --houkai
  • 3. re: tomcat7的配置
  • @ftp123
    你娘里个大雪碧 里面会有common这个文件夹吗 不知道还尼玛在这瞎比比 纯尼玛误导人 我最恶心的就是这样没事装逼的人 艹
  • --cao
  • 4. re: tomcat7的配置
  • 从哪抄来的,是抄的,你也说声啊,要不自己测试下也可以,害人测试半天。
  • --ftp123
  • 5. re: tomcat7的配置
  • %TOMCAT_HOME%\common\lib 从tomcat6.0开始已经没有common文件夹了,直接用\lib,害我找了半天common文件夹啊,赶快改过来吧
  • --寒澈

阅读排行榜

评论排行榜