The SWF::DisplayItem Module

Each object that is on-screen at any particular time has an entry in a data structure in the SWF player called the display list. The display list keeps track of the position of the object, the depth of the object, and a transformation matrix that affects how the object is drawn on the screen. The SWF::DisplayItem object defines methods for moving, transforming, and arranging objects in the display list. The following attributes are contained in a DisplayItem:

Name

A label used to refer to the item in ActionScript scripts

Position

The x, y coordinate of the item within a frame

Scale

A horizontal and vertical scale multiplier

Rotation

An angular offset

Skew

A horizontal and vertical skew offset

Depth

The position of the item in the display list

Ratio

If the displayed item is a Morph object, the ratio attribute determines which frame of the morph transition is displayed

Color transform

The object’s red, green, blue, and alpha components may have a color offset applied to them

DisplayItems do not have their own constructors. New DisplayItems are created when a displayable object is added to a movie or a sprite; the add( ) method of these objects returns an SWF::DisplayItem object.

In the example at the beginning of this chapter, we moved the various items around the Stage using an ActionScript event loop. Example 9-1 creates a 60-frame animation where each shape is manually placed within the frame by maintaining a list of DisplayItems for each object on the Stage.

Example 9-1. Using ...

Get Perl Graphics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.