User Guide
314 ActionScript classes
var mc:MovieClip = this.createEmptyMovieClip("mc",
this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
trace("0x" + myBitmapData.getPixel(0, 0).toString(16)); // 0xcccccc
See also
getPixel32 (BitmapData.getPixel32 method)
getPixel32 (BitmapData.getPixel32 method)
public getPixel32(x:Number, y:Number) : Number
Returns an ARGB color value that contains alpha channel data and RGB data. This method is
similar to the
getPixel() method, which returns an RGB color without alpha channel data.
Availability: ActionScript 1.0; Flash Player 8
Parameters
x:Number - The x position of the pixel.
y:Number - The y position of the pixel.
Returns
Number - A number that represent an ARGB pixel value. If the (x, y) coordinates are outside
the bounds of the image, 0 is returned. If the bitmap was created as an opaque bitmap and not
a transparent one, then this method will return an error code of -1.
Example
The following example uses the
getPixel32() method to retrieve the ARGB value of a pixel
at a specific x and y position:
import flash.display.BitmapData;
var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xFFAACCEE);
var mc:MovieClip = this.createEmptyMovieClip("mc",
this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
var alpha:String = (myBitmapData.getPixel32(0, 0) >> 24 &
0xFF).toString(16);
trace(">> alpha: " + alpha); // ff
var red:String = (myBitmapData.getPixel32(0, 0) >> 16 & 0xFF).toString(16);
trace(">> red: " + red); // aa