DisplayObject

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 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.

Search Great Flex/Flash Sites