Sprite

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 FlexShape class is a very small class that extends the Flash Shape class and sets its name property to a unique identifier and overrides the toString() method to return a dot separated path to the Flash Stage.

The behavior is fully explained in the article on Intermediary Flex classes along with FlexSprite which has an identical implementation.

The FlexSprite class is a very small class that extends the Flash Sprite class and sets its name property to a unique identifier and overrides the toString() method to return a dot separated path to the Flash Stage.

The behavior is fully explained in the article on Intermediary Flex classes along with FlexShape which has an identical implementation.

These classes mediate between Flash and Flex and provide some minor translation of the functionality of Flash into the functionality expected by Flex. FlexSprite and FlexShape translate the name property and toString() method into the expected behavior in Flex.

Both classes have essentially the same functionality. In their constructor, they perform an assignment such as this (from FlexSprite):

  1.       name = NameUtil.createUniqueName(this);

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.

Search Great Flex/Flash Sites