Create custom MXML components

When I define a custom property in my MXML component, I also want to define a set of possible values โ€‹โ€‹for this property so that I can show Flex Builder (possible values โ€‹โ€‹for a custom property) when I call the code completion function.

Any idea how this can be done?

+7
flex actionscript-3 flash-builder
source share
2 answers

Use the [Inspectable] meta tag with the enumeration attribute.

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

 [Inspectable(defaultValue="abc", enumeration="abc,xyz,pqr")] public var myProp:Boolean; 
+9
source share

Your Mxml part of custom compoenent, like mine:

  <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: -

 //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; } 
+1
source share

All Articles