当我在MXML组件中定义自定义属性时,我也想定义该属性的一组可能值,以使Flex Builder在调用代码完成功能时显示它们(自定义属性的可能值)。
有什么好的方法可以实现吗?
有什么好的方法可以实现吗?
使用具有enumeration
属性的[Inspectable]元标记。
[Inspectable]
元数据标记定义有关组件属性的信息,您可以在代码提示和Flex Builder的属性检查器区域中公开该信息。
[Inspectable(defaultValue="abc", enumeration="abc,xyz,pqr")]
public var myProp:Boolean;
你的自定义组件的Mxml部分,就像我的一样:
<com:CustomWindow width="100" height="130" frontImageSrc="{rp.currentItem.path}"
showText="{rp.currentItem.imgtext}" hideImage="{rp.currentItem.noImage}"
buttonMode="true" useHandCursor="true" mouseChildren="true"/>
动作脚本部分是:
//Inspectable metadata tag gives you the option in the flex builder
//to choose an option from the available selected options
//Put it with the getter of that particular property
[Inspectable(defaultValue="true", enumeration="true,false")]
public function get showImage():Boolean
{
return _imgVisible;
}
public function set showImage(str:Boolean):void
{
_imgVisible = str;
}