Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 47

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Using metadata tags
The Flex compiler recognizes component metadata statements in your ActionScript class files
and MXML files. The metadata tags define component attributes, data binding properties,
events, and other properties of the component. Flex interprets these statements during
compilation; they are never interpreted during run time.
Metadata statements are associated with a class declaration, an individual data field, or a
method. They are bound to the next line in the file. When you define a component property
or method, add the metadata tag on the line before the property or method declaration.
In an ActionScript file, when you define component events or other aspects of a component
that affect more than a single property, you add the metadata tag outside the class definition
so that the metadata is bound to the entire class, as the following example shows:
// Add the [Event] metadata tag outside of the class file.
[Event(name="enableChange", type=flash.events.Event)]
public class ModalText extends TextArea {
...
// Define class properties/methods
private var _enableTA:Boolean;
// Add the [Inspectable] metadata tag before the individual property.
[Inspectable(defaultValue="false")]
public function set enableTA(val:Boolean):void {
_enableTA = val;
this.enabled = val;
// Define event object, initialize it, then dispatch it.
var eventObj:Event = new Event("enableChange");
dispatchEvent(eventObj);
}
}
About metadata tags
47

Advertisement

Table of Contents
loading

Table of Contents