User Guide

122 Creating Simple Visual Components in ActionScript
Flex components are implemented as a class hierarchy in ActionScript. Each component in
your application is an instance of an ActionScript class. The following example shows just a
portion of this hierarchy:
All Flex visual components are derived from the ActionScript UIComponent class. To create
your own components, you can create a subclass from the UIComponent class, or from any of
its subclasses.
The class you choose to use as the superclass of your custom component depends on what you
are trying to accomplish. For example, you might require a custom button control. You could
create a subclass of the UIComponent class, then recreate all of the functionality built into the
Flex Button class. A better and faster way to create your custom button component is to create
a subclass of the Flex Button class, and then modify it in your custom class.
This topic describes how to create simple ActionScript components. Simple components are
subclasses of existing Flex components that modify the behavior of the component, or add
new functionality to it. For example, you might add a new event type to a Button control, or
modify the default styles or skins of a DataGrid control.
You can also create advanced ActionScript components. Advanced ActionScript components
might have one of the following requirements:
Modify the appearance of a control or the layout functionality of a container
Encapsulate one or more components into a composite component
Subclass UIComponent to create components
For information on creating advanced ActionScript components, see Chapter 10, “Creating
Advanced Visual Components in ActionScript,” on page 147.
NOTE
This example shows a portion of the class hierarchy. For a complete description of the
class hierarchy, see the Adobe Flex 2 Language Reference.
Container NumericStepperButton
ComboBase
UIComponent
Form
VBox
Box ComboBox