Chapter 9. DRAWING WITH PIXELS

While largely known for its focus on vector assets, Flash has been gaining attention in the field of manipulating pixel-based assets, as well. This began in earnest with the introduction of Flash 8, as a large new set of bitmap-related functionality was introduced. Included was a set of blend modes, basic filters (like drop shadow and bevel, akin to Photoshop layer styles), and advanced filter effects (like convolution and displacement mapping, akin to Photoshop filters). Even the ability to temporarily treat vectors like bitmaps, behind the scenes with no loss in vector quality, was introduced for a dramatic performance improvement.

Today, the speed increases afforded by ActionScript 3.0, in Flash Player 9 and later, make bitmap manipulation practical in more processor-intensive scenarios than ever before. In this chapter, we’ll discuss several ways to add pixel-pushing to your projects, including:

  • Bitmap Caching. Moving pixels on screen is a lot more efficient than recalculating the math required to display moving vectors upon every frame rate. Temporarily caching a bitmap representation of a vector-based asset can reduce this strain and increase performance.

  • The BitmapData Class. Just as the Graphics class is used to draw with vectors, the BitmapData class can be used to draw with pixels. We’ll look at a small subset of its most useful methods.

  • Blend Modes. Another useful and efficient bitmap compositing tool is the blend mode. Flash offers a standard ...

Get Learning ActionScript 3.0 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.