Drawing vectors with code brings with it special benefits. Included among them is the freedom to create assets on the fly, rather than be committed strictly to art drawn or imported at author-time. Related to this is the additional bonus of reduced file size, because assets are created at runtime rather than occupying space in your SWF. Smaller files mean your projects are delivered more quickly to the end user, and the experience is more enjoyable.
In this chapter, we'll focus on the first of two ways to create visual assets with code—drawing vectors. The next chapter will focus on creating and compositing bitmaps.
Graphics class. This class, casually referred to as
the drawing API in its prior incarnation, contains methods for
drawing vectors. You have control over stroke and fill attributes,
and can move a virtual pen tool around choosing where to draw lines,
curves, and shapes like circles and rectangles.
Geometry package. This utility package contains
classes for creating points and rectangles, as well as transforming
objects and their color, and creating matrices for complex
simultaneous changes to rotation, scaling, and x and y translation.
Using matrices, it's possible to achieve affects for which no
properties exist, including skew and shear.
9-slice Scaling. Through the use of a dynamically assignable rectangle, you can employ 9-slice scaling to prevent the sides and corners of a sprite or movie clip from distorting when scaled.