关于FlexBuilder的Event注释

如果某个类派发某事件, 我们通常使用如下注释:

/** * Dispatched when …. * @eventType com.events.MyEvent.EVENT_TEST */
[Event(name=”myEvent” type=”com.events.MyEvent”)]

 

在使用new testr().addEvent…时提示的Const是错误的.MyEvent.MY_EVENT

解决方法:

[Event(name=”eventTest” type=”com.events.myevent”)]
此时的提醒为MyEvent.EVENT_TEST
[]中的name应与Event中的const的名字 如EVENT_TEST:String = "myEvent"; 中的EVENT_TEST对应 ,’_"后的字母保留大写去掉下划线->eventTest即可.

 

注意: Flex框架中的事件, 其Const 与String的name都是想对应的.

==>不得不承认 这样子比较挫<==

所以在编写自定义事件时, 最好也遵守这个不成文的规定:

public static const EVENT_EO_EDITOR:String = "eventEoEditor";

而不是随便乱写一个String, 这样便于在其他派发该事件的类中编写事件注释.

This entry was posted in Flex and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>