UIObject and UIComponent are the base classes of the v2 component architecture. Both define methods and properties that all other components share, including a system for component creation. Understanding the principles at work in these two classes is important for building components.
UIObject directly subclasses MovieClip. By providing a wrapper around its methods and properties, it makes the syntax more intuitive and improves the conceptual management of representing graphic objects with movie clips.
A UIObject or UIObject subclass resizes itself by scaling. When you change its size using the size() method, the new dimensions are handed to the _width and _height movie clip properties, which scale the subclass.
The UIObject and UIObject subclasses broadcast their events just before drawing, analogous to the enterFrame() movie clip event. UIObject also defines the styling, skinning, and event aspects of the component architecture.
UIComponent is a subclass of UIObject. It defines high-level behaviors that are
specific to a graphic object. UIComponent handles end-user interactions
(clicking, dragging, focus, etc.) and component enabling and disabling. It
also offers
the draw() method, which you can override to customize how UIComponent handles calls to
its size() method. UIComponent inherits all the methods, properties, and events of UIObject.
Each component subclass defines methods that are specific to its task as a component, but there are a few methods that every component implements, which guarantee that the component takes advantage of system-level services provided by UIObject and UIComponent:
init() method should call the init() method of the superclass—for example, super.init(). Additionally, init() may set initial values for properties.draw() method to make subObjects visible and perform the initial layout.setSize() is called on a component. Components should override this method to lay out
subObjects every time the component's size changes.