ITPub博客

首页 > 应用开发 > IT综合 > Flex元数据标签之[Event]

Flex元数据标签之[Event]

IT综合 作者:杨幂打真三 时间:2015-08-26 21:09:03 0 删除 编辑

转:http://blog.csdn.net/mnorst/article/details/6735751
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. 


用法如下:


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

[Event]标签的属性如下:



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


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


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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29032948/viewspace-1783495/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Flex Event标签
请登录后发表评论 登录
全部评论

注册时间:2015-06-03

  • 博文量
    28
  • 访问量
    83677