Placement coordinates of bitmapData in AS3

Posted by TheDarkIn1978 on Stack Overflow See other posts from Stack Overflow or by TheDarkIn1978
Published on 2010-04-06T15:33:26Z Indexed on 2010/04/06 15:53 UTC
Read the original article Hit count: 515

Filed under:
|

i've programatically created a vector graphic (rect), repositioned the graphic, and set up an MOUSE_MOVE eventListener to trace color information of the graphic using getPixel(). however, the bitmapData is placed at 0,0 of the stage and i don't know how to move it so that it matches the graphic's location.

var coloredSquare:Sprite = new GradientRect(200, 200, 0xFFFFFF, 0x000000, 0xFF0000, 0xFFFF00);
coloredSquare.x = 100;

addChild(coloredSquare);

var coloredSquareBitmap:BitmapData = new BitmapData(coloredSquare.width, coloredSquare.height, true, 0);
coloredSquareBitmap.draw(coloredSquare);

coloredSquare.addEventListener(MouseEvent.MOUSE_MOVE, readColor);
function readColor(evt:Event):void
    {
    var pixelValue:uint = coloredSquare.getPixel(mouseX, mouseY);
    trace(pixelValue.toString(16));
    }

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about bitmapdata