setPixel32 (BitmapData.setPixel32 method)

public setPixel32(x:Number, y:Number, color:Number) : Void

Sets the color and alpha transparency values of a single pixel of a BitmapData object. This method is similar to the setPixel() method; the main difference is that the setPixel32() method takes an ARGB color value that contains alpha channel information.

Availability: ActionScript 1.0; Flash Player 8

Parameters

x:Number - The x position of the pixel whose value changes.

y:Number - The y position of the pixel whose value changes.

color:Number - The ARGB color to which to set the pixel. If you created an opaque (not a transparent) bitmap, the alpha transparency portion of this color value is ignored.

Example

The following example uses the setPixel32() method to assign an ARGB value to a pixel at a specific x and y position. You can draw on the created bitmap in 0x000000 without an alpha value by pressing you mouse button and dragging.

import flash.display.BitmapData;

var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xFFCCCCCC);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

mc.onPress = function() {
    this.onEnterFrame = sketch;
}

mc.onRelease = function() {
    delete this.onEnterFrame;
}

function sketch() {
    myBitmapData.setPixel32(_xmouse, _ymouse, 0x00000000);
}

See also

getPixel32 (BitmapData.getPixel32 method), setPixel (BitmapData.setPixel method)


Version 8

 

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

Current page: http://livedocs.adobe.com/flash/8/main/00001968.html