i've created a bitmap with data and placed it into a sprite so to receive mouse events. however, i'm struggling with reading the BitmapData within the sprite.
function showBitmapData(e:Event):void
{
var bData:BitmapData = new BitmapData(video.width, video.height);
bData.draw(video);
var bmap:Bitmap = new Bitmap(bData);
bmap.x = 220;
bmap.y = 20;
bmap.scaleX = bmap.scaleY = 2;
canvas = new Sprite;
addChild(canvas);
canvas.addChild(bmap);
//Mouse Track Pixel Colors
canvas.addEventListener(MouseEvent.CLICK, readPixel);
}
function readPixel(e:MouseEvent):void
{
var hex:uint = e.bmap.bData.getPixel32(mouseX, mouseY); // <- is the problem?
var pixelAlpha:int = (hex >>> 0x18) & 0xff;
var red:int = (hex >>> 0x10) & 0xff;
var green:int = (hex >>> 0x08) & 0xff;
var blue:int = hex & 0xff;
colorText.text = "Red:" + red + " Green:" + green + " Blue:" + blue + " Alpha:" + pixelAlpha;
}