UIComponent
This is a teaser for my upcoming talk at 360|Flex San Jose. I will be talking about how to improve your programming by reading the Flex source code. You should come to the conference (even if you aren't interested in my talk). There are lots of other great speakers.
Choosing a base class for your Flex component involves understanding the base classes that Flash provides. The primary classes in Flash that you should recognize are Sprite, Shape, and TextField. These classes are by far the most common in Flex code and you need to know what capabilities and limitations they have.
The updateComplete event is dispatched from all UIComponents after they have been through the validation phase in the rendering lifecycle. It is called after the commitProperties(), measure(), and updateDisplayList() methods have been called.
This method will only be called when the component is invalidated. Some components will not be invalidated very often during their lifecycle if their size is constant and they do not perform rendering updates or have their properties changing. Other components, however, will dispatch this event quite often as they respond to user input or other events to update themselves.
UIComponent is the core class in Flex 3 for all of the interactive classes. Its class hierarchy is UIComponent < FlexSprite < Sprite < DisplayObjectContainer < InteractiveObject < DisplayObject. A UIComponent can render graphics using the drawing API (from Sprite), have other DisplayObjects as children (from DisplayObjectContainer) and supports mouse and keyboard interaction (from InteractiveObject). But the real work in UIComponent is in basic Flex functionality it implements.
UIComponent defines the core interaction of the Flex 3 component model such as styles, tooltips, validators, states, repeaters, invalidation, measuring, layout, and rendering. The Flash classes such as Sprite do not follow these standards and are not constrained and supported by the Flex component model. This is an important consideration when choosing a base class for custom components.
The Flex SDK is a large body of code that Adobe has released under an open source license. Reading the Flex source code is one of the best habits to develop as a Flex developer. The code provides insight into what Adobe engineers were thinking during development and how they expect their components to be used. The code is also intended as a blueprint for implementing your own components.
