Fitting Bitmaps Inside Shapes
Problem
You want to place a bitmap inside a shape with an irregular border.
Solution
Apply a bitmap fill to a vector shape, erase the edges of the bitmap, or use a mask.
Discussion
Flash offers three ways of filling a shape with a bitmap. No approach is better than the others in terms of file size in the exported .swf file, but each has its own intrinsic benefits, as discussed next. The three ways are:
Draw a vector shape, and set its fill to any bitmap in the movie’s library.
Place an instance of a bitmap on the stage and erase its edges.
Reveal an area of a bitmap using a mask.
You can apply a bitmap as the fill for an existing vector shape. This approach is useful if you’ve already drawn the vector shape, if a vector drawing tool exists that can create your shape for you (such as the Oval tool if you need to fill an ellipse), or if you are more comfortable drawing with a vector tool to create a shape than you would be trying to recreate that shape with a freehand tool, such as the Eraser tool.
Another benefit of this approach is that it is the only way to give a specific shape a tiled fill. That is, if the shape is larger than the bitmap, Flash repeats the bitmap to fill in the rest of the shape.
In addition, because the bitmap is being used as a fill, you have all the functionality of the Fill Transform tool at your disposal, which makes it easy to rotate, scale, distort, and reposition the fill relative to the shape.
To add a bitmap fill, complete the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access