Metadata Tag [Inspectable]

Anyone can briefly explain the [Inspectable] metadata tag. I read and could not understand in living documents.

Please help me when we use the [Inspectable] metadata tag?

Thanks, Ravi

+4
source share
2 answers

The tag is used with properties to provide code hints for this property and to indicate a possible list of values ​​that the property can take when used in mxml. Unlike the [Bindable] metadata, this tag has little effect on the way the code works (other than specifying a default value) - this is mainly used to indicate the direction of Flex Builder regarding how to handle a particular property.

[Inspectable] metadata tag

Defines the attribute that is provided to users of the component in the attribute tooltips and Flex Builder tag meter. Also limits valid property values.

For example, the verticalScrollPolicy property of the mx.core.Container class has the following [Inspectable] tag.

 [Inspectable(category="General", enumeration="off,on,auto", defaultValue="auto")] public function get verticalScrollPolicy():String { return _verticalScrollPolicy; } 

This tells Flex Builder that this property should appear on the General tab (this is the β€œCommon” in my FB) of the Flex Builder Property inspector (open the mxml file, go to the Windows menu and select Flex Properties to open the Property inspector - at the top inspector tabs, next to its name, you will find buttons for switching to standard view, category view and alphabetical view). This property can take one of three values off , on , auto , and if none is specified, it takes auto as the default value.

I have never used this tag, and I believe that you will not use it either, unless you are writing a Flex API that will be used by a wider audience than your colleagues (or if you are a perfectionist).

+6
source

This tag is useful when writing your own custom components. Although it does not interact with the actual code that you are writing (unlike the [Bindable] tag mentioned above), it gives the Flexbuilder environment a way to give the user the ability to set the properties of your component using the user interface designer.

Therefore, the tag is useful if you want:

  • Write components to be used by others (make Inspectable properties publicly available)
  • You have created a user component that is used several times in the user interface (possibly an advanced slider). You then write some Inspect'able getter / setter methods as a public API for your component, and then implement these getter / setter methods to validate the data and implement the internal logic of your component.

More details and examples here . Some good information on writing custom components (using the methodology underlying the code that I prefer) can be found here .

Note When creating open properties using [Inspectable] they don't seem to appear in the Flex-Properties Flex-Properties panel (but not in the standard view), use the category view or alphabetical order instead)

Note. You can find an alternative method of adding common properties to your custom components using MXLM, like this .

+1
source

All Articles