as3中类定义前的方括号

Dan*_*iel 4 flash actionscript-3

我已经看过在类定义之前使用的embed标签,但我刚看到Keith正在使用这些..

[Event(name="select", type="flash.events.Event")]
[Event(name="close", type="flash.events.Event")]
[Event(name="resize", type="flash.events.Event")]
public class Window extends Component{
Run Code Online (Sandbox Code Playgroud)

谁能告诉我这是做什么的?

Tyl*_*eto 9

最重要的是,Flex编译器在解释MXML时使用它.但实际上它只是元数据,ASDocs和一些代码完成实现将使用它来向您显示可用事件,但这就是它.

它在这里的文档:http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_3.html

希望有所帮助!

(回答编辑更准确)

  • 如果需要,您也可以制作自己的元数据.例如,你可以拥有像[[Divillysausages(someVar ="value")]`这样的元数据.你需要在项目编译器设置中指定`-keep-as3-metadata + = Divillysausages`,你可以通过`describeType()`函数来访问它 (4认同)