我使用 FlashDevelop3 R2 和 Flex 3.3 SDK 进行开发,在很多情况下我必须使用嵌入元数据标签:
[Embed(source="path/to/file")]
private var Asset:Class;
我很好地理解上述所有内容,并且我很感激它的存在,因为我不喜欢打开 Flash IDE 太频繁了。
当我最近浏览其他作者的课程时,我发现了一个我不理解的有趣的元数据标签:
[Event(name="", type="")]
我还没有看到我需要这个的情况,而且我真的不明白它的用途。
预先感谢您的帮助。
布莱恩·霍奇
blog.hodgedev.com hodgedev.com
I develop with FlashDevelop3 R2 and the Flex 3.3 SDK and there are many occasions where I must use the embed metadata tag as such:
[Embed(source="path/to/file")]
private var Asset:Class;
I understand the above all well and good, and I am thankful it exists because I do not like to open the flash IDE too often.
When I am going through other authors classes lately, I have found an interesting metadata tag that I do not understand:
[Event(name="", type="")]
I have yet to see a situation where I require this, and furthermore I really just do not understand what it is for.
Thank in advance for your help.
Brian Hodge
blog.hodgedev.com hodgedev.com
发布评论
评论(2)
这些
[Event(name, type)]
声明描述了类实例可能调度哪些事件。它们实际上对于代码完成很有用 - 例如,当您键入:
mySprite.addEventListener(
)时,您的代码编辑器(Flex Builder 或 FlashDevelop)将显示有意义的事件列表,这些事件 因此,您可以在代码中添加这些声明,并从更丰富的代码完成中受益。
另请注意,这适用于自定义事件类(请参阅 FlashDevelop 的新事件类模板)。
These
[Event(name, type)]
declarations describe which events a class instance is likely to dispatch.They are actually useful for code completion - for instance when you type:
mySprite.addEventListener(
, your code editor (Flex Builder or FlashDevelop) will display a meaningful list of events that this object can dispatch.So you can add these declarations in your code and benefit from a richer code completion.
Also note that this works with custom Event classes (see FlashDevelop's new Event class template).
我们使用它来将自定义事件绑定到自定义 MXML 组件。 该标签允许您从 MXML 引用它。 请参阅文档:
但是,如果您尝试引用未使用事件元标记声明的 mxml 标记上的事件,编译器会发出警告。
We use it for binding custom events to our custom MXML components. This tag allows you to reference it from MXML. See documentation:
The compiler will complain, however, if you try to refer to an event on an mxml tag that was not declared with an event metatag.