得到影片剪辑的颜色 [英] get the color of movieClip

查看:202
本文介绍了得到影片剪辑的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从影片剪辑的颜色。我根据下列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);
}

这篇关于得到影片剪辑的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆