import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.geom.Point;
import flash.geom.Rectangle;
var bmd1:BitmapData = new BitmapData(200, 200, true, 0xFFCCCCCC);
var seed:int = int(Math.random() * int.MAX_VALUE);
var channels:uint = BitmapDataChannel.RED | BitmapDataChannel.BLUE;
bmd1.perlinNoise(100, 80, 12, seed, false, true, channels, false, null);
var bitmap1:Bitmap = new Bitmap(bmd1);
addChild(bitmap1);
var bmd2:BitmapData = new BitmapData(200, 200, true, 0xFFCCCCCC);
var pt:Point = new Point(0, 0);
var rect:Rectangle = new Rectangle(0, 0, 200, 200);
var threshold:uint = 0x00800000;
var color:uint = 0x20FF0000;
var maskColor:uint = 0x00FF0000;
bmd2.threshold(bmd1, rect, pt, ">", threshold, color, maskColor, true);
var bitmap2:Bitmap = new Bitmap(bmd2);
bitmap2.x = bitmap1.x + bitmap1.width + 10;
addChild(bitmap2);
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.geom.Point;
import flash.geom.Rectangle;
var bmd:BitmapData =new BitmapData(200,200, true,0xFFFF0000);
var bmdMask:BitmapData =new BitmapData(200,200, true);
var seed:int=int(Math.random() *int.MAX_VALUE);
var channels:uint= BitmapDataChannel.RED | BitmapDataChannel.BLUE;
bmdMask.perlinNoise(100, 80, 12, seed, false, true,channels, false, null);
var bitmap:Bitmap =new Bitmap(bmd);
var bitmapMask:Bitmap =new Bitmap(bmdMask);
//addChild(bitmap);
//addChild(bitmapMask);
var threshold:uint= 0x00800000;
var color:uint= 0x00FFFFFF;
var maskColor:uint= 0x00FF0000;
bmdMask.threshold(bmdMask, bmdMask.rect, new Point(), ">",threshold, color, maskColor, true);
var spriteMask =new Sprite();
spriteMask.addChild(bitmapMask);
spriteMask.cacheAsBitmap =true;
addChild(spriteMask);
var display =new Sprite();
display.addChild(bitmap);
display.cacheAsBitmap =true;
addChild(display);
display.mask = spriteMask;