attachBitmap (MovieClip.attachBitmap method)

public attachBitmap(bmp:BitmapData, depth:Number, [pixelSnapping:String], [smoothing:Boolean]) : Void

Attaches a bitmap image to a movie clip.

After the bitmap is attached to the movie clip, a reference is made from the movie clip to the bitmap object. When attaching a bitmap, you can specify pixelSnapping and smoothing parameters to affect the appearance of the bitmap.

After an object is added to the movie clip, it is not an accessible object. The depth, pixelSnapping, and smoothing parameters can only be set during the attachBitmap() method call and cannot be changed later.

First use the createEmptyMovieClip() to create an empty movie clip, then use the attachBitmap() method. This way, you can apply transformations to the movie clip to transform the bitmap; for example, by using the matrix property of the movie clip.

Pixel snapping forces the position of the bitmap to the nearest whole pixel value instead of positioning to be on a partial pixel. There are three pixel snapping modes:

Smoothing mode affects the appearance of the image when it is scaled.

Availability: ActionScript 1.0; Flash Player 8

Parameters

bmp:BitmapData - A transparent or opaque bitmap image.

depth:Number - An integer that specifies the depth level within the movie clip where the bitmap image should be placed.

pixelSnapping:String [optional] - The pixel snapping modes are auto, always, and never. The default mode is auto.

smoothing:Boolean [optional] - The smoothing mode is either true for enabled or false for disabled. The default mode is disabled.

Example

The following attaches a very basic bitmap to a movie clip:

import flash.display.*;

this.createEmptyMovieClip("bmp1", this.getNextHighestDepth());
var bmpData1:BitmapData = new BitmapData(200, 200, false, 0xaa3344);
bmp1.attachBitmap(bmpData1, 2, "auto", true);

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


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001893.html