Chapter 33. Drawing Bitmap Graphics Programmatically
Introduction
In this chapter
Understanding bitmap data
Copying bitmap data by pixels, color channels, and other methods
Applying fills
Using color transforms
Working with bitmap effects
Using noise
Applying filters
Flash Player 9 contains an API for working with bitmaps. The flash.display.BitmapData
class is the main focus with regard to bitmaps, and it has methods for getting and setting pixels, applying pixel dissolves, setting threshold settings, applying filters, and more. In this chapter, you look at how to work with the new API to achieve a variety of effects.
Creating a BitmapData Object
There are several ways to construct or retrieve a new BitmapData
object in ActionScript:
You can use the constructor to make a new, blank
BitmapData
object with specific dimensions and background.If you have an embedded asset (embedded with the
[Embed]
tag in Flex Builder or with a library symbol in Flash authoring) you can construct a newBitmap
orBitmapAsset
instance using the class name you assigned to the embedded asset, and retrieve thebitmapData
property from it.
In the following sections, you look at how to use those ways to construct or retrieve BitmapData
objects. No matter how you want to work with bitmaps via ActionScript, you'll need to use at least one of those ways to create and retrieve a reference to the object.
Using the constructor method
You can construct a new BitmapData
object using the constructor method as part of a new
statement. ...
Get ActionScript™ 3.0 Bible 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.