7

当我在 MXML 组件中定义自定义属性时,我还想定义该属性的一组可能值,以便在调用代码完成函数时显示 Flex Builder(自定义属性的可能值)。

知道怎么做吗?

4

2 回答 2

9

使用带有属性的[Inspectable]元标记。enumeration

[Inspectable]元数据标签定义了有关您在代码提示和 Flex Builder 的属性检查器区域中公开的组件属性的信息。

[Inspectable(defaultValue="abc", enumeration="abc,xyz,pqr")]
public var myProp:Boolean;
于 2010-06-21T05:29:38.833 回答
1

您的自定义组件的 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;
}
于 2010-06-21T11:47:38.223 回答