拾色器,就是我们通常看到的选择组件,这里推荐一款国外闪客写的拾色器组件,使用方法很简单,可以在组件的属性窗口中设置初始颜色,设置实例名,然后引用 output 属性来获得颜色值。
该组件制作时间稍早,因此不具备自动升至最高层的能力,需要用 DepthManager 来助一把力。示例代码如下:
我的拾色器的实例名为 mypc , 调用方法为 mypc.output
import mx.managers.DepthManager;
mypc.setDepthTo(DepthManager.kTop);
var tl_x = tl_y = 50;
var br_x = 350;
var br_y = 250;
function inDrawScope() {
//在画线范围内
if (_xmouse > tl_x && _xmouse < br_x && _ymouse > tl_y && _ymouse < br_y) {
return true;
} else {
return false;
}
}
createEmptyMovieClip("xian", 1);
var beginDraw = false;
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
with (xian) {
lineStyle(2, mypc.output, 100);
if (beginDraw && inDrawScope()) {
if (pt_x < tl_x) {
pt_x = tl_x;
}
if (pt_y < tl_y) {
pt_y = tl_y;
}
if (pt_x > br_x) {
pt_x = br_x;
}
if (pt_y > br_y) {
pt_y = br_y;
}
moveTo(pt_x, pt_y);
lineTo(_xmouse, _ymouse);
}
pt_x = _xmouse;
pt_y = _ymouse;
}
};
mouseListener.onMouseDown = function() {
pt_x = _xmouse;
pt_y = _ymouse;
beginDraw = true;
trace("down");
};
mouseListener.onMouseUp = function() {
beginDraw = false;
trace("up");
};
Mouse.addListener(mouseListener);
组件下载
点击下载该文件