AS3 [事件(名称="",类型=""),有何意义?有何、意义、名称、类型

2023-09-09 21:43:11 作者:浮生半世〆

我发展与FlashDevelop3 R2和Flex 3.3 SDK和有多次在那里我必须使用嵌入元数据标签为这样的:

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;

据我所知,上面的都很好,我很感谢它的存在,因为我不喜欢过于频繁开闪光灯的IDE。

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.

布赖恩·霍奇 blog.hodgedev.com hodgedev。 COM

推荐答案

我们用它来绑定自定义事件给我们的自定义MXML组件。这个标签允许你从MXML中引用它。请参阅documentation:

We use it for binding custom events to our custom MXML components. This tag allows you to reference it from MXML. See documentation:

[事件(名称=enableChanged,键入=对象类型:flash.events.Event)]

类ModalText扩展文本区{    ...   }

< MyComp:ModalText enableChanged =handleEnableChangeEvent(事件);/>

,编译器会抱怨然而,如果试图引用一个事件上,这不是与事件的元标记声明的MXML标签。

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.