O'Reilly logo

Learning ActionScript 3.0 by Zevan Rosser, Rich Shupe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. DRAWING WITH VECTORS

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.

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

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

  • Applied ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required