Read pixel from Sprite?

From the graphics of a sprite, I need to read pixel color from sprite.mouseX, sprite.mouseY, I could not find getPixel of graphics in docs, how would I achieve this?

Pretty sure you’ll have to use BitmapData.draw().

I tried BitmapData.draw() , but how would I draw the shape when its pixels are on negative coordinate?
I’ve found that it will work fine when top-left pixel on shape graphics is on zero, zero

Any idea?

var matrix:Matrix = new Matrix();
matrix.translate(10, 10);
bitmapData.draw(sprite, matrix);

This will move the image 10 pixels right and 10 pixels down before drawing it.

You can also use getBounds to get the rectangle for an object if you don’t know it already

Right. If you want to draw the entire sprite, you’d do this:

var spriteBounds:Rectangle = sprite.getBounds(sprite);
var matrix:Matrix = new Matrix();
matrix.translate(-spriteBounds.x, -spriteBounds.y);

var bitmapData:BitmapData = new BitmapData(
    Math.ceil(sprite.width), Math.ceil(sprite.height),
    true, 0x00000000);
bitmapData.draw(sprite, matrix);

Awesome, thank you, by the way, I feel as I am competing with time, to finish converting my app to html5 before chrome drops the default support of adobe flash! that’s very close, I think this December… wish me luck!