Flash
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 TextField class is one of the most basic classes in Flash for dealing with text. The TextField class is designed for dynamic and potentially interactive text. The text can be selectable or not and it supports multiline text and text formatting using basic HTML and CSS. Its inheritance is TextField < InteractiveObject < DisplayObject.
The Shape class is the most basic Flash class that supports rendering through the graphics property. The Shape hierarchy is: Shape < DisplayObject.
The InteractiveObject class is a core class in Flash player. InteractiveObject is an abstract base class so you cannot create instances of it. Also, you cannot subclass it yourself because it is not a complete class. InteractiveObject is a subclass of DisplayObject and adds support for interacting with the user of the Flash application. Flash classes which are not subclasses of InteractiveObject, such as Shape and StaticText, do not respond to mouse or keyboard actions.
Some of the core classes in the Flash player are actually abstract classes. Even though you cannot instantiate these classes directly, they are still very important to understand. These classes are the parent classes for all of the visual display classes in Flash and they contribute functionality to the concrete classes that you will use in your application.
The display list is the mechanism that Flash uses to render itself onto the users screen. The display list is rooted in the Stage class and consists of all of its descendants (children, grandchildren, and so forth). DisplayObjects on the display list have a specific rendering lifecycle and event propagation mechanism. Objects which are not on the display list will not be rendered and cannot interact with user events.
More to come...
The Flash drawing API is the primary mechanism for rendering interactive graphics outside of the Flash editing environment. The drawing API is a low-level interface that draws primitives such as lines, curves, and triangles (in Flash 10). It can style those primitives with line styles and fill styles that get their content from vector gradients or bitmaps.
The Sprite class is one of the most basic rendering classes available in Flash. It supports the Flash drawing API, can contain other DisplayObjects, and supports user interaction events. Sprite does not have a timeline like MovieClip which makes it smaller and faster if you are not running timeline-based animations. The Sprite class is the base class which most UI components inherit from such as the UIComponent in Flex.
The addedToStage event fires when a component becomes part of the display list. The display list is rooted in the Stage component and contains all of its descendants. When your component is on the Stage it participates in the standard render loop and the event dispatching loop.
Keep in mind that even though your component is not in the display list, it can still be asked to render itself using the draw method of BitmapData.
The DisplayObject class is the parent class for all visual components in the Flash player. Every class that can render to the Stage inherits from DisplayObject. Common subclasses of DisplayObject that you may be familiar with include Sprite, Shape, Bitmap, and MovieClip.
