
162 Customizing Components
Specifying the package
Define your custom components within an ActionScript package. The package reflects the
directory location of your component within the directory structure of your application.
package myComponents
{
// Class definition goes here.
}
Defining the class
The class definition must be prefixed by the public keyword, as the following example shows:
// Class definition goes here.
public class MyButton extends Button {
// Define properties, constructor, and methods.
}
Defining the constructor
If the class is missing a constructor, add it. A constructor for a child class of UIComponent
must have no required arguments; it can only have optional ones.
Here is a typical constructor:
public function Button() {
super();
className = "Button";
btnOffset = 0;
}
Creating bindable properties
In Flex 1.5, you use the [ChangeEvent] metadata tag to define a property as bindable. In Flex
2.0, you use the
[Bindable] metadata tag. For more information, see Creating and Extending
Flex 2 Components.
Commentaires sur ces manuels