您的位置:首页 > 其它

Flex元数据标签之[Event]

2011-08-31 14:31 507 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: