Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClip > beginBitmapFill (MovieClip.beginBitmapFill method) | |||
public beginBitmapFill(bmp:BitmapData, [matrix:Matrix], [repeat:Boolean], [smoothing:Boolean]) : Void
Fills a drawing area with a bitmap image. The bitmap can be repeated or tiled to fill the area.
Availability: ActionScript 1.0; Flash Player 8
bmp:BitmapData - A transparent or opaque bitmap image.
matrix:Matrix [optional] - A matrix object (of the flash.geom.Matrix class), which you can use to define transformations on the bitmap. For instance, you can use the following matrix to rotate a bitmap by 45 degrees (pi/4 radians):
var matrix = new flash.geom.Matrix(); matrix.rotate(Math.PI/4);
repeat:Boolean [optional] - If true, the bitmap image repeats in a tiled pattern. If false, the bitmap image does not repeat, and the edges of the bitmap are used for any fill area that extends beyond the bitmap.
For example, consider the following bitmap (a 20 x 20-pixel checkerboard pattern):
When repeat is set to true (as in the following example), the bitmap fill repeats the bitmap:
When repeat is set to false, the bitmap fill uses the edge pixels for the fill area outside of the bitmap:
smoothing:Boolean [optional] - If false, upscaled bitmap images are rendered using a nearest-neighbor algorithm and look pixelated. If true, upscaled bitmap images are rendered using a bilinear algorithm. Rendering using the nearest neighbor-algorithm is usually much faster. The default value for this parameter is false.
The following code defines a simple bitmap, and then uses beginBitmapFill() to fill a movie clip with that bitmap tiled:
import flash.display.*;
import flash.geom.*;
var bmpd:BitmapData = new BitmapData(20,20);
var rect1:Rectangle = new Rectangle(0,0,10,10);
var rect2:Rectangle = new Rectangle(0, 10, 10, 20);
var rect3:Rectangle = new Rectangle(10, 0, 20, 10);
var rect4:Rectangle = new Rectangle(10, 10, 20, 20);
bmpd.fillRect(rect1, 0xAA0000FF);
bmpd.fillRect(rect2, 0xAA00FF00);
bmpd.fillRect(rect3, 0xAAFF0000);
bmpd.fillRect(rect4, 0xAA999999);
this.createEmptyMovieClip("bmp_fill_mc", this.getNextHighestDepth());
with (bmp_fill_mc) {
matrix = new Matrix();
matrix.rotate(Math.PI/8);
repeat = true;
smoothing = true;
beginBitmapFill(bmpd, matrix, repeat, smoothing);
moveTo(0, 0);
lineTo(0, 60);
lineTo(60, 60);
lineTo(60, 0);
lineTo(0, 0);
endFill();
}
bmp_fill_mc._xscale = 200;
bmp_fill_mc._yscale = 200;
If your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001895.html
Comments
TessandraFae said on Oct 10, 2007 at 7:34 AM :