User Guide
330 ActionScript classes
sourceRect:flash.geom.Rectangle - A rectangle that defnes the area of the source image
to use as input.
destPoint:flash.geom.Point - The point within the destination image (the current
BitmapData instance) that corresponds to upper-left corner of the source rectangle.
operation:String - One of the following comparison operators, passed as a String: "<",
"<=", ">", ">=", "==", "!="
threshold:Number - The value that each pixel is tested against to see if it meets or exceeds
the threshhold.
color:Number [optional] - The color value that a pixel is set to if the threshold test succeeds.
The default is 0x00000000.
mask:Number [optional] - The mask to use to isolate a color component. The default value is
0xFFFFFFFF.
copySource:Boolean [optional] - A Boolean value. If the value is true, pixel values from the
source image are copied to the destination when the threshold test fails. If the value is
false,
the source image is not copied when the threshold test fails. The default value is
false.
Returns
Number - The number of pixels that were changed.
Example
The following example shows how to change the color value of pixels whose color value is
greater than or equal to a certain threshold.
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var mc:MovieClip = this.createEmptyMovieClip("mc",
this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
myBitmapData.fillRect(new Rectangle(0, 0, 50, 80), 0x00FF0000);
mc.onPress = function() {
myBitmapData.threshold(myBitmapData, new Rectangle(0, 0, 100, 40), new
Point(0, 0), ">=", 0x00CCCCCC, 0x000000FF, 0x00FF0000, false);
}