加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex元数据标签之[Event]

发布时间:2020-12-15 01:17:47 所属栏目:百科 来源:网络整理
导读:Flex中引入了元数据标签的概念,这些标签并没有被编译到SWF文件中,而只是告诉编译器如何生成SWF 文件。 [Event] 使用[Event]标签定义MXML中的事件属性及组件生成的事件对象的类型。[Event]标签插入到ActionScript文件的类定义前,或者MXML文件的mx:Metadata

Flex中引入了元数据标签的概念,这些标签并没有被编译到SWF文件中,而只是告诉编译器如何生成SWF 文件。


[Event]

使用[Event]标签定义MXML中的事件属性及组件生成的事件对象的类型。[Event]标签插入到ActionScript文件的类定义前,或者MXML文件的<mx:Metadata>块内。

Use the [Event] metadata tag to define the MXML property for an event and the data type of the event object that a component emits. You insert the [Event] metadata tag before the class definition in an ActionScript file,or in the <mx:Metadata> block in an MXML file.?


用法如下:

[Event(name="eventName",type="package.eventType")]

[Event]标签的属性如下:

属性
类型
描述
eventName
String
指定事件名称,包括包名。
eventType
String
指定定义事件对象的数据类型的类。类名可以是事件基类,Events或者Events的子类。必须包含包名。
??

用法--下面的例子指定了组件可广播的事件为myClickEvent:

[Event(name="myClickEvent",type="flash.events.Event")]


如果在MXML中调用未使用 [Event]定义的事件,则MXML编译时会报错
If you do not identify an event in the class file with the [Event] metadata tag,the MXML compiler generates an error if you try to use the event name in MXML

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读