flex里的[Inspectable]标签用于为as类的属性定义一些可供flex代码提示等使用的信息,比如属性的类型啦合法值啦默认值啦之类的,[Inspectable]标签可以用在属性上,也可以用在getter/setter方法上,写法如下:
[Inspectable(attribute=value[,attribute=value,…])]
property_declaration name:type;
[Inspectable(category="General", enumeration="round,bevel,miter", defaultValue="round")]
setter_getter_declarations;
[Inspectable]标签有如下属性:
Property |
Type |
Description |
category |
String |
在flex的属性检查器里把该属性分类到指定类别,默认的分类是“Other”,可选值包括: “Common”,“Effects”,“Events”, "General",“Layout Constraints”,“Size”, “Style”,“Other” |
defaultValue |
String/Number |
当你在flex属性检查器里设置该属性时所显示的默认值 |
enumeration |
String |
用逗号分隔指定一系列合法值,只有这些值才允许设置,例如“test1,test2,test3”,注意值与值之间不要使用空格,否则flex会认为空格是值的一部分(除非你确实想这样啦),这信息会出现在代码提示和属性检查器里 |
environment |
String |
? |
format |
String |
设定属性检查器使用什么组件来显示该属性,例如假如你有一个format=”Color”的属性,编辑时属性检查器会弹出颜色编辑器,常用值包括: ”Length”,“Color”,“Time”, “EmbededFile”,”File” |
listOffset |
Number |
? |
name |
String |
设定属性的显示名,例如“Font Width” |
type |
String |
设定属性的类型,如果忽略则使用属性本身的数据类型,可选值如下: Array,Boolean,Color,Font Name,List,Number,Object,String |
variable |
String |
指定参数所绑定的变量名 |
verbose |
Number |
? |
?
例如下面这样的代码:
[Inspectable(type="String",enumeration="left,center,right")] public var labelPlacement:String = LabelPlacement.LEFT;
在flex/flashbuilder上编辑时,就会在弹出的代码提示框,提示可选的值.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|