User Guide

136 Creating Components
Selecting a parent class
The first thing to decide when creating a component is whether to extend one of the version 2
classes. If you choose to extend a version 2 class, you can either extend a component class (for
example, Button, CheckBox, ComboBox, List, and so on) or one of the base classes,
UIObject or UIComponent. All the component classes, except the Media components,
extend the base classes; if you extend a component class, the class automatically inherits from
the base classes as well.
The two base classes supply common features for components. By extending these classes,
your component begins with a basic set of methods, properties, and events.
You dont have to create a subclass UIObject or UIComponent or any other classes in the
version 2 framework. Even if your component classes inherit directly from the MovieClip
class, you can use many powerful component features: export to a SWC file or compiled clip,
use built-in live preview, view inspectable properties, and so on. However, if you want your
components to work with the Macromedia version 2 components, and use the manager
classes, you need to extend UIObject or UIComponent.
The following table briefly describes the version 2 base classes:
Base class Extends Description
mx.core.UIObject
MovieClip UIObject is the base class for all graphical objects. It can
have shape, draw itself, and be invisible.
UIObject provides the following functionality:
Editing styles
Event handling
Resizing by scaling
mx.core.UIComponent
UIObject UIComponent is the base class for all components.
UIComponent provides the following functionality:
Creating focus navigation
Creating a tabbing scheme
Enabling and disabling components
Resizing components
Handling low-level mouse and keyboard events