![MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual Download Page 49](http://html1.mh-extra.com/html/macromedia/flex-developing-components-and-themes/flex-developing-components-and-themes_manual_3388115049.webp)
Writing the component’s ActionScript code
49
About the UIObject and UIComponent classes
Components based on version 2 of the Macromedia Component Architecture descend from the
UIObject class, which wraps the MovieClip class. The MovieClip class is the base class for the
classes in Flash that can draw on the screen. By providing a wrapper around its methods and
properties, Flex makes the UIObject syntax more intuitive and improves the conceptual
management of representing graphic objects.
Many MovieClip properties and methods are related to the Timeline. The UIObject class
abstracts many of those details. Subclasses of the MovieClip class do not use unnecessary
MovieClip properties and methods. However, you can access these properties and methods, if
you want.
The UIObject (mx.core.UIObject) class hides the mouse handling and frame handling in the
MovieClip class. The UIObject class also defines the styles, skins, and event aspects of the
component architecture. The UIObject class and its subclasses broadcast their events just before
drawing. If you are familiar with Flash, this event is analogous to the
enterFrame()
MovieClip
event. The UIObject class posts events to its listeners just before drawing when loading and
unloading, and when its layout changes (
move
,
resize
).
A UIObject class or UIObject subclass resizes itself by scaling. When you change its size using the
setSize()
method, the new dimensions are handed to the
_width
and
_height
properties of the
MovieClip class, which scale the subclass.
The UIComponent (mx.core.UIComponent) class is a subclass of the UIObject class. It defines
high-level behaviors that are specific to a graphical object. The UIComponent class handles end-
user interactions (such as clicking and focus) and component enabling and disabling. The
UIComponent class inherits all the methods, properties, and events of the UIObject class.
The UIComponent class also handles dragging, but you should not override the
startDrag()
method when defining custom components.
Extending other classes
You can extend any component class to create a new component class. For example, if you want to
create a component that behaves almost the same as a Button component does, you can extend
the Button class instead of recreating all the functionality of the Button class from the base classes.
To make component construction easier, you can extend a subclass for any class in the component
architecture; you do not need to extend the UIObject or UIComponent class directly. If you
extend any other component’s class, you extend these base classes by default, because all
components are subclasses of the UIComponent class, which is a subclass of the UIObject class.
When you add dependent components, you should override the
createChildren()
and
layoutChildren()
methods to instantiate, position, and resize the components properly.