In addition to importing assets, or creating them in the Flash authoring environment, you can include assets in your projects by drawing them dynamically with ActionScript at runtime. Much of the last half of this book will take advantage of this approach to minimize the number of custom assets required, and let you generate content exclusively with code. For that reason, this section starts off with a brief introduction to drawing with code.
A code-only approach doesn’t easily offer the artistic range afforded if you can use imported or hand-drawn assets, but significant tradeoffs include increased flexibility and reduced file size. Indeed, an entirely new creative horizon becomes available with code-generated art, and using ActionScript combined with previously created assets is, of course, the best of both worlds.
You have two primary methods of drawing with code: manipulating
vectors with the
Graphics class, and
manipulating pixels with the
and/or related classes. This chapter will primarily focus on the former,
but will also discuss a few simple pixel-based techniques, such as bitmap
caching and basic filters.
To effectively demonstrate some of the concepts in this chapter, you need to use a display object or two. Part I and Part II of this book covered the creation and use of display objects throughout, and you’ll look at some of those concepts again in Chapter 13. For clarity, however, the first recipe in this ...