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()
Availability: ActionScript 1.0; Flash Player 8
Parameters
- The x position of the pixel.
x:Number
- The y position of the pixel.
y:Number
Returns
- A number that represent an ARGB pixel value. If the (x, y) coordinates are outside
Number
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
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
314
ActionScript classes
method, which returns an RGB color without alpha channel data.
method to retrieve the ARGB value of a pixel
getPixel32()
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?