我想从影片剪辑的颜色。我根据下列code:
I want to get the color from the movieclip. I am Using Following Code:
for (var j = 0; j <bmpd.width; j++)
{
for (var k = 0; k <bmpd.height; k++)
{
trace("0x"+bmpd.getPixel(j,k).toString(16))
}
}
下面圈是一个MovieClip.please指导我
Here Circle is a MovieClip.please guide me
为了让您的影片剪辑颜色在某一个点或范围,应创建所需的容量(1×1的点)的透明的BitmapData,和0x0填充颜色,然后创建的BitmapData的变换矩阵对齐(0,0)到您所在区域的左上角,然后绘制了MC的位图,然后就可以查询它的像素。一个例子(一个点):
To get a color on your MovieClip at a certain point or range, you should create a transparent BitmapData of required capacity (1x1 for point), fill it with 0x0 color, then create a transform matrix aligning (0,0) of BitmapData to upper left corner of your region, then draw that MC on the bitmap, then you can query its pixels. An example (a point):
private static var hitTestBD:BitmapData=new BitmapData(1,1,true,0);
private static vat hitTestMatrix:Matrix=new Matrix();
public static function getMCColor(mc:DisplayObject,tx:Number,ty:Number):uint {
hitTestMatrix.identity();
hitTestMatrix.translate(-1*tx,-1*ty); // aligning
hitTestBD.fillRect(hitTestBD.rect,0x0);
hitTestBD.draw(mc,hitTestMatrix);
return hitTestBD.getPixel32(0,0);
}