Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating custom MXML components

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?

like image 806
Worker Avatar asked Jun 21 '10 05:06

Worker


2 Answers

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;
like image 172
Amarghosh Avatar answered Sep 19 '22 06:09

Amarghosh


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;
}
like image 33
Ankur Sharma Avatar answered Sep 19 '22 06:09

Ankur Sharma