7

When I define custom propertie in my MXML component, I also want to define a set of possible values of that property to make Flex Builder show then (possible values of the custom property) when I invoke code completion function.

Any idea how it could be done?

Worker
  • 2,411
  • 6
  • 29
  • 55

2 Answers2

9

Use the [Inspectable] metatag with enumeration attribute.

The [Inspectable] metadata tag defines information about an attribute of your component that you expose in code hints and in the Property inspector area of Flex Builder.

[Inspectable(defaultValue="abc", enumeration="abc,xyz,pqr")]
public var myProp:Boolean;
Amarghosh
  • 58,710
  • 11
  • 92
  • 121
1

Your Mxml part of the custom compoenent , as mine is :

 <com:CustomWindow width="100" height="130" frontImageSrc="{rp.currentItem.path}" 
   showText="{rp.currentItem.imgtext}" hideImage="{rp.currentItem.noImage}" 
   buttonMode="true" useHandCursor="true" mouseChildren="true"/>

Actionscript part is : -

//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;
}
Amarghosh
  • 58,710
  • 11
  • 92
  • 121
Ankur Sharma
  • 538
  • 4
  • 16