UIComponent.document是Application

来源:互联网 发布:手机淘宝首页分类 编辑:程序博客网 时间:2024/04/29 12:47

Flex的UI组件(包括Application)都有document属性。

该属性的官方定义是:引用与此 UIComponent 相关联的文档对象。文档对象是位于 Flex 应用程序、MXML 组件或 AS 组件层次结构顶层的 Object。

 

在Flex中,文档类是mx.managers.SystemManager。难道document指的是SystemManager?

不是。指的是Application。

验证如下:

执行结果是:信息框没有显示文字"1"。

信息框显示文字:“2”和“3”。

显示2说明document就是Application。

显示3说明mx_internal命名空间的_document也是Applicaiton。

<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"    xmlns:s="library://ns.adobe.com/flex/spark"    xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()"><fx:Script><![CDATA[import mx.controls.Alert;public function init():void{if(this.document == this.systemManager){Alert.show("1");}if(this.document == this){Alert.show("2");}if(this.document == mx_internal::_document){Alert.show("3");}}]]></fx:Script></s:Application>


 

参考:

编译器生成的代码文件:主程序_ generated.as的构造函数中有如下代码

        mx_internal::_document = this;


 

 

原创粉丝点击