纯代码颜色拾取器,当鼠标移动到位图上,旁边方块可拾取并对应的颜色,演示效果见底部…

设计思路:侦听鼠标移动事件,获取位图当前像素点的颜色值,并赋值给小方块…

参考代码:package{

import flash.display.Sprite;

import flash.events.MouseEvent;

import flash.display.BitmapData;

import flash.geom.Matrix;

import flash.geom.colorTransform;

public Class Main():void{

private var a:Sprite;

private xin:BitmapData();

public function Main():void{

init();

}

private function init():void{

var tu:Pic=new Pic(1,1);

var tut:Bitmap=new Bitmap(pic);

addChild(tut);

 

a.graphics.beginFill(0x00ff00);

a.graphics.drawRect(0,0,80,80);

a.graphics.endFill();

a.x=100;

a.y=100;

addChild(a);

xin=new BitmapData(1,1,false,0x0);

stage.addEventListener(MouseEvent.Mouse_MOVE,qu);

}

private function qu(evt:MouseEvent):void{

xin.draw(stage,new Matrix(1,0,0,1,-mouseX,-mouseY));

var mycolor:ColorTransform=new ColorTransform();

mycolor.color=xin.getPixl();

a.transform.colorTransform=mycolor;

}

}

}

    博视界科技专注于沉浸式全景数字餐厅、全息酒店宴会厅,旨在帮传统餐饮用科技玩跨界,欢迎咨询!

官方网站:www.boseetech.com

联系方式:    

关注我们:


    【声明】转载本文请注明出处三人行设计,并保留有效链接:flash as3 颜色拾取器 http://www.srxtuan.com/archives/1408,谢谢!

猜您还喜欢: