开发者

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 proper开发者_开发百科ty 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?


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;


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜