fscommand("allowscale", "false");
var lightColor = 0xFFFFFF;
var darkColor = 0x9D9DA1;
var bgColor = 0xEEEEEE;
genColorPicker();
init("007f7f", 0);
function genColorPicker() {
var depth = 0;
var TF = new TextFormat();
TF.font = "Arial";
TF.size = 12;
this.beginFill(bgColor);
drawRect(this, 288, 160, 0, 0, .5, darkColor, lightColor);
this.endFill();
this.createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 116, 15, 5, 5);
this.createEmptyMovieClip("mcOldColor", depth++);
with (mcOldColor) {
_x = 5;
_y = 5;
beginFill(0x000000);
drawRect(mcOldColor, 58, 15, 0, 0, .5, 0x000000, 0x000000);
endFill();
}
this.createEmptyMovieClip("mcNewColor", depth++);
with (mcNewColor) {
_x = 63;
_y = 5;
beginFill(0xFF0000);
drawRect(mcNewColor, 58, 15, 0, 0, .5, 0xFF0000, 0xFF0000);
endFill();
}
drawRect(mcBorder, 62, 15, 158, 5);
this.createTextField("tfLabel", depth++, 131, 3, 27, 16);
with (tfLabel) {
selectable = false;
text = "Hex:";
setTextFormat(TF);
}
this.createTextField("tfHex", depth++, 158, 3, 62, 19);
with (tfHex) {
type = "input";
restrict = "0-9A-F";
maxChars = 6;
setNewTextFormat(TF);
tfHex.onKillFocus = hexChg;
}
this.createEmptyMovieClip("mcNone", depth++);
with (mcNone) {
_x = 252;
_y = 5;
beginFill(bgColor);
drawRect(mcNone, 15, 15, 0, 0, .5, darkColor, lightColor);
endFill();
beginFill(0xFFFFFF);
drawRect(mcNone, 9, 9, 3, 3);
endFill();
lineStyle(2, 0xFF0000);
moveTo(4, 11);
lineTo(11, 4);
drawRect(mcNone, 9, 9, 3, 3, .5, 0x000000, 0x000000);
mcNone.useHandCursor = false;
mcNone.onPress = function() {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcNone.onRelease = mcNone.onDragOut=function () {
with (_parent) {
var myColor = new Color(mcOldColor);
tfHex.text = ("000000"+myColor.getRGB().toString(16)).substr(-6);
hexChg();
tfHex.text = "";
drawRect(this, 15, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
this.createEmptyMovieClip("mcMode", depth++);
with (mcMode) {
_x = 268;
_y = 5;
drawRect(mcMode, 15, 15, 0, 0, .5, darkColor, lightColor);
mcMode.chgMode = function(mode) {
with (this) {
var arrMc = [_parent.mcMixer, _parent.mcSwatches];
for (var i = 0; i<arrMc.length; i++) {
arrMc[i]._visible = 0;
}
arrMc[Mode]._visible = 1;
switch (mode) {
case 0 :
colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
alphas = [100, 100, 100, 100, 100, 100, 100];
ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
matrix = {matrixType:"box", x:3, y:3, w:9, h:9, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
_parent.drawRect(this, 9, 9, 3, 3);
colors = [0x808080, 0x808080];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:3, y:3, w:9, h:9, r:0.5*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
_parent.drawRect(this, 9, 9, 3, 3, .5, 0x000000, 0x000000);
endFill();
break;
case 1 :
beginFill(0xFF0000);
_parent.drawRect(this, 4.5, 4.5, 3, 3, .5, 0x000000, 0x000000);
beginFill(0x00FF00);
_parent.drawRect(this, 4.5, 4.5, 7.5, 3, .5, 0x000000, 0x000000);
beginFill(0x0000FF);
_parent.drawRect(this, 4.5, 4.5, 3, 7.5, .5, 0x000000, 0x000000);
beginFill(0xFFFF00);
_parent.drawRect(this, 4.5, 4.5, 7.5, 7.5, .5, 0x000000, 0x000000);
endFill();
break;
}
}
};
mcMode.useHandCursor = false;
mcMode.onPress = function() {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcMode.onRelease = mcMode.onDragOut=function () {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, darkColor, lightColor);
}
mode = mode == 0 ? 1 : 0;
chgMode(mode);
};
}
this.createEmptyMovieClip("mcMixer", depth++);
with (mcMixer) {
_visible = 0;
createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 96, 96, 5, 25);
createEmptyMovieClip("mcBoardHS", depth++);
with (mcBoardHS) {
_x = 5;
_y = 25;
var colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
var alphas = [100, 100, 100, 100, 100, 100, 100];
var ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
var matrix = {matrixType:"box", x:0, y:0, w:96, h:96, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBoardHS, 96, 96);
endFill();
colors = [0x808080, 0x808080];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:96, h:96, r:0.5*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBoardHS, 96, 96);
endFill();
createEmptyMovieClip("mcMask", 1);
mcMask.beginFill(0x000000);
drawRect(mcMask, 96, 96);
mcMask.endFill();
createEmptyMovieClip("mcPoint", 0);
with (mcPoint) {
_x = 1;
_y = 1;
lineStyle(.5, 0xFFFFFF);
moveTo(0, 1);
lineTo(0, 5);
moveTo(1, 0);
lineTo(5, 0);
moveTo(0, -1);
lineTo(0, -5);
moveTo(-1, 0);
lineTo(-5, 0);
setMask(mcMask);
}
mcBoardHS.useHandCursor = false;
mcBoardHS.onPress = function() {
mcPoint._x = _xmouse;
mcPoint._y = _ymouse;
Mouse.hide();
_parent._parent.adjustHsl();
this.onMouseMove = function() {
this.mcPoint._x = this._xmouse>0 && this._xmouse<96 ? this._xmouse : (this._xmouse<=0 ? 1 : 95);
this.mcPoint._y = this._ymouse>0 && this._ymouse<96 ? this._ymouse : (this._ymouse<=0 ? 1 : 95);
this._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
Mouse.show();
delete this.onMouseUp;
delete this.onMouseMove;
};
};
}
drawRect(mcBorder, 15, 96, 106, 25);
createEmptyMovieClip("mcLighteness", depth++);
with (mcLighteness) {
_x = 106;
_y = 25;
createEmptyMovieClip("mcBg", 0);
with (mcBg) {
beginFill(0x7F7F7F);
drawRect(mcBg, 15, 96, 0, 0, 0, 0x7F7F7F);
endFill();
}
createEmptyMovieClip("mcLighteness", 1);
with (mcLighteness) {
colors = [0xFFFFFF, 0xFFFFFF, 0x000000, 0x000000];
alphas = [100, 0, 0, 100];
ratios = [0x00, 0x7F, 0x80, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:15, h:96, r:.5*Math.PI};
mcLighteness.beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcLighteness, 15, 96);
endFill();
mcLighteness.useHandCursor = false;
mcLighteness.onPress = function() {
if (_ymouse>0 && _ymouse<96) {
_parent.mcArrow._y = _ymouse;
}
Mouse.hide();
_parent._parent._parent.adjustHsl();
this.onMouseMove = function() {
this._parent.mcArrow._y = this._ymouse>0 && this._ymouse<96 ? this._ymouse : (this._ymouse<=0 ? 1 : 95);
this._parent._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseUp;
delete this.onMouseMove;
Mouse.show();
};
};
}
createEmptyMovieClip("mcArrow", 2);
with (mcArrow) {
_x = 16;
_y = 1;
beginFill(0x000000);
lineTo(5, -4.5);
lineTo(5, 4.5);
lineTo(0, 0);
endFill();
mcArrow.useHandCursor = false;
mcArrow.onPress = function() {
offsetY = _ymouse;
_parent._parent._parent.adjustHsl();
this.onMouseMove = function() {
this.t = this._parent._ymouse-this.offsetY;
this._y = this.t>0 && this.t<96 ? this.t : (this.t<=0 ? 1 : 95);
this._parent._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseUp;
delete this.onMouseMove;
delete this.offsetY;
delete this.t;
};
};
}
}
var arrRGBHSL = ["R", "G", "B", "H", "S", "L"];
for (var i = 0; i<6; i++) {
var y = 25+i*16.5+(i>2 ? 2 : 0);
drawRect(mcBorder, 100, 12, 143, y);
drawRect(mcBorder, 25, 12, 248, y);
createEmptyMovieClip("mcFader"+arrRGBHSL[i], depth++);
eval("mcFader"+arrRGBHSL[i]).limit = arrRGBHSL[i] == "H" ? 359 : (arrRGBHSL[i] == "S" || arrRGBHSL[i] == "L" ? 100 : 255);
eval("mcFader"+arrRGBHSL[i]).flag = arrRGBHSL[i];
with (eval("mcFader"+arrRGBHSL[i])) {
_x = 131;
_y = y;
createTextField("tfLabel", 6, -2, -3, 15, 16);
with (tfLabel) {
selectable = false;
text = arrRGBHSL[i]+":";
setTextFormat(TF);
}
createTextField("tfValue", 5, 118, -3, 26, 16);
with (tfValue) {
type = "input";
text = 0;
restrict = "0-9";
maxChars = 3;
//setNewTextFormat(TF);
}
tfValue.onKillFocus = tfValue.onChanged=function () {
if (this.text == "") {
this.text = 0;
} else if (this.text>limit) {
this.text = limit;
} else {
this.text = parseInt(this.text);
}
_parent._parent.update(flag == "R" || flag == "G" || flag == "B" ? 0 : 1);
};
createEmptyMovieClip("mcBox", 10);
with (mcBox) {
_x = 13;
beginFill(0x000000);
drawRect(mcBox, 4, 12, 0, 0, 0, 0x000000, 0x000000);
endFill();
beginFill(0xFFFFFF);
drawRect(mcBox, 2, 12, 1, 0, 0, 0xFFFFFF, 0xFFFFFF);
endFill();
mcBox.useHandCursor = false;
mcBox.onPress = function() {
offsetX = _xmouse;
this.onMouseMove = function() {
this.t = this._parent._xmouse-this.offsetX;
this.t = this.t>12 && this.t<107 ? this.t : (this.t<=12 ? 13 : 107);
if (this.t>12 && this.t<107) {
this._x = this.t;
this._parent.tfValue.text = Math.round((this.t-13)*this._parent.limit/94);
this._parent._parent._parent.update(this._parent.flag == "R" || this._parent.flag == "G" || this._parent.flag == "B" ? 0 : 1);
}
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseMove;
delete this.onMouseMove;
delete this.t;
delete this.offsetX;
};
};
}
createEmptyMovieClip("mcUp", 3);
with (mcUp) {
_x = 145;
_y = -.5;
beginFill(bgColor);
drawRect(mcUp, 7, 6, 0, 0, .5, darkColor, lightColor);
beginFill(0x000000);
moveTo(3.5, .5);
lineTo(0.5, 5.5);
lineTo(6.5, 5.5);
lineTo(3.5, .5);
endFill();
mcUp.useHandCursor = false;
mcUp.onPress = function() {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, lightColor, darkColor);
}
iv0 = setInterval(prepare, 500);
up();
};
mcUp.prepare = function() {
iv1 = setInterval(up, 1);
clearInterval(iv0);
};
mcUp.up = function() {
if (_parent.tfValue.text<_parent.limit) {
_parent.tfValue.text++;
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
}
};
mcUp.onRelease = mcUp.onDragOut=function () {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, darkColor, lightColor);
}
clearInterval(iv0);
clearInterval(iv1);
};
}
createEmptyMovieClip("mcDown", 2);
with (mcDown) {
_x = 145;
_y = 6;
beginFill(bgColor);
drawRect(mcDown, 7, 6, 0, 0, .5, darkColor, lightColor);
beginFill(0x000000);
moveTo(3.5, 5.5);
lineTo(0.5, .5);
lineTo(6.5, .5);
lineTo(3.5, 5.5);
endFill();
mcDown.useHandCursor = false;
mcDown.onPress = function() {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, lightColor, darkColor);
}
iv0 = setInterval(prepare, 500);
down();
};
mcDown.prepare = function() {
iv1 = setInterval(down, 1);
clearInterval(iv0);
};
mcDown.down = function() {
if (_parent.tfValue.text>0) {
_parent.tfValue.text--;
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
}
};
mcDown.onRelease = mcDown.onDragOut=function () {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, darkColor, lightColor);
}
clearInterval(iv0);
clearInterval(iv1);
};
}
createEmptyMovieClip("mcBg", 4);
with (mcBg) {
_x = 12;
beginFill(0xFFFFFF);
drawRect(mcBg, 100, 12);
endFill();
mcBg.useHandCursor = false;
mcBg.onPress = function() {
_parent.tfValue.text = Math.round(_xmouse*_parent.limit/100);
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
this.onMouseMove = function() {
this.t = this._xmouse>=0 && this._xmouse<=100 ? this._xmouse : (this._xmouse<0 ? 0 : 100);
this._parent.tfValue.text = Math.round(this.t*this._parent.limit/100);
this._parent._parent._parent.update(this._parent.flag == "R" || this._parent.flag == "G" || this._parent.flag == "B" ? 0 : 1);
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.t;
delete this.onMouseUp;
delete this.onMouseMove;
};
};
}
if (flag == "L") {
createEmptyMovieClip("mcLighteness", 7);
with (mcLighteness) {
_x = 12;
colors = [0xFFFFFF, 0xFFFFFF, 0x000000, 0x000000];
alphas = [100, 0, 0, 100];
ratios = [0x00, 0x7F, 0x80, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:96, h:12, r:-1*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcLighteness, 100, 12);
endFill();
}
} else if (flag == "H") {
createEmptyMovieClip("mcHue", 7);
with (mcHue) {
_x = 12;
colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
alphas = [100, 100, 100, 100, 100, 100, 100];
ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:100, h:10, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcHue, 100, 12);
endFill();
swapDepths(mcBg);
}
} else if (flag == "R" || flag == "G" || flag == "B" || flag == "S") {
createEmptyMovieClip("mcBegin", 8);
with (mcBegin) {
colors = [flag == "S" ? 0x808080 : 0x000000, flag == "S" ? 0x808080 : 0x000000];
alphas = [100, 0];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:12, y:0, w:100, h:12, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBegin, 100, 12, 12);
endFill();
}
createEmptyMovieClip("mcEnd", 7);
with (mcEnd) {
colors = [0x000000, 0x000000];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:12, y:0, w:100, h:12, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcEnd, 100, 12, 12);
endFill();
}
if (flag == "S") {
mcBg.swapDepths(9);
}
}
}
}
}
this.createEmptyMovieClip("mcSwatches", depth++);
with (mcSwatches) {
_visible = 0;
var arrColor = new Array();
var arrNum = new Array("00", "33", "66", "99", "CC", "FF");
var arrBaseColor = new Array("000000", "333333", "666666", "999999", "CCCCCC", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "00FFFF", "FF00FF");
for (var i = 0; i<12; i++) {
arrColor[arrColor.length] = arrBaseColor[i];
for (var j = 0; j<18; j++) {
arrColor[arrColor.length] = arrNum[Math.floor(i/6)*3+Math.floor(j/6)]+arrNum[j%6]+arrNum[i%6];
}
arrColor[arrColor.length] = "000000";
for (var j = 0; j<15; j++) {
var t = (Math.round((1-(i*15+j)/179)*255)).toString(16);
t = t.length>1 ? t : "0"+t;
t = t.toUpperCase();
arrColor[arrColor.length] = t+t+t;
}
}
var cols = 35;
for (var i = 0; i<Math.ceil(arrColor.length/cols); i++) {
for (var j = 0; j<cols; j++) {
var t = i*cols+j<arrColor.length ? arrColor[i*cols+j] : "000000";
createEmptyMovieClip("mc"+t+i+j, depth++);
var mc = eval("mc"+t+i+j);
with (mc) {
_y = 25+i*8;
_x = (j>19 ? 3 : 5)+j*8;
beginFill(parseInt(t, 16));
drawRect(mc, (j == 19 ? 6 : 8), 8, 0, 0, .5, 0x0000000, 0x000000);
endFill();
}
mc.onRollOver = function() {
with (_parent) {
this.t = tfHex.text;
tfHex.text = this._name.substr(2, 6);
hexChg();
}
with (mcBorder) {
_visible = 1;
_x = this._x;
_y = this._y;
_width = this._width;
_height = this._height;
}
};
mc.onPress = function() {
_parent.tfHex.text = this.t=this._name.substr(2, 6);
};
mc.onRollOut = mc.onDragOut=function () {
_parent.tfHex.text = this.t;
_parent.hexChg();
mcBorder._visible = 0;
};
}
}
createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 8, 8, 0, 0, .5, 0xFFFFFF, 0xFFFFFF);
mcBorder._visible = 0;
}
this.createTextField("tfCopyright0", depth++, 6, 141, 283, 20);
with (tfCopyright0) {
selectable = false;
html = true;
htmlText = "<p align=/"right/"><font size=/"10/" face=/"Arial/" color=/"#FFFFFF/"><a href=/" http://www.nlimi.com/" target=/"_blank/">Copyright (c) Afeila Studio All rights reserved.</p>";
}
this.createTextField("tfCopyright", depth++, 5, 140, 283, 20);
with (tfCopyright) {
selectable = false;
html = true;
htmlText = "<p align=/"right/"><font size=/"10/" face=/"Arial/" color=/"#999999/">Copyright (c) Afeila Studio All rights reserved.</p>";
}
this.createEmptyMovieClip("mcReset", depth++);
with (mcReset) {
_x = 5;
_y = 126;
beginFill(bgColor);
drawRect(mcReset, 89, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 89, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">Reset</p>";
}
mcReset.useHandCursor = false;
mcReset.onPress = function() {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcReset.onRelease = mcReset.onDragOut=function () {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, darkColor, lightColor);
var myColor = new Color(mcOldColor);
tfHex.text = ("000000"+myColor.getRGB().toString(16)).substr(-6);
hexChg();
}
};
}
this.createEmptyMovieClip("mcOK", depth++);
with (mcOK) {
_x = 99;
_y = 126;
beginFill(bgColor);
drawRect(mcOK, 90, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 90, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">OK</p>";
}
mcOK.useHandCursor = false;
mcOK.onPress = function() {
with (_parent) {
drawRect(this, 90, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcOK.onRelease = mcOK.onDragOut=function () {
with (_parent) {
drawRect(this, 90, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
this.createEmptyMovieClip("mcCancel", depth++);
with (mcCancel) {
_x = 194;
_y = 126;
beginFill(bgColor);
drawRect(mcCancel, 89, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 89, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">Cancel</p>";
}
mcCancel.useHandCursor = false;
mcCancel.onPress = function() {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcCancel.onRelease = mcCancel.onDragOut=function () {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
}
function init(initColor, mode) {
tfHex.text = initColor;
hexChg();
mode = mode != null ? mode : 0;
mcMode.mode = mode;
mcMode.chgMode();
var myColor = new Color(mcOldColor);
myColor.setRGB(parseInt(tfHex.text, 16));
}
function hexChg() {
tfHex.text += "000000".substr(0, 6-tfHex.text.length);
with (mcMixer) {
mcFaderR.tfValue.text = parseInt(tfHex.text.substr(0, 2), 16);
mcFaderG.tfValue.text = parseInt(tfHex.text.substr(2, 2), 16);
mcFaderB.tfValue.text = parseInt(tfHex.text.substr(4, 2), 16);
update(0);
}
}
function drawRect(mc, w, h, oX, oY, lW, c0, c1) {
oX = oX != null ? oX : 0;
oY = oY != null ? oY : 0;
c0 = c0 != null ? c0 : lightColor;
c1 = c1 != null ? c1 : darkColor;
with (mc) {
moveTo(w+oX, oY);
lineStyle(lW != null ? lW : .5, c0);
lineTo(w+oX, h+oY);
lineTo(oX, h+oY);
lineStyle(lW != null ? lW : .5, c1);
lineTo(oX, oY);
lineTo(w+oX, oY);
}
}
function adjustHsl() {
with (mcMixer) {
var h = (mcBoardHS.mcPoint._x-1)*359/94;
var s = (95-mcBoardHS.mcPoint._y)*100/94;
var v = (95-mcLighteness.mcArrow._y)*100/94;
mcFaderH.tfValue.text = Math.round(h);
mcFaderS.tfValue.text = Math.round(s);
mcFaderL.tfValue.text = Math.round(v);
}
update(1);
}
function update(mode) {
with (mcMixer) {
switch (mode) {
case 0 :
var hsl = rgbToHsl(parseInt(mcFaderR.tfValue.text), parseInt(mcFaderG.tfValue.text), parseInt(mcFaderB.tfValue.text));
mcFaderH.tfValue.text = Math.round(hsl.h);
mcFaderS.tfValue.text = Math.round(hsl.s*100);
mcFaderL.tfValue.text = Math.round(hsl.l*100);
break;
case 1 :
var rgb = hslToRgb(parseInt(mcFaderH.tfValue.text), parseInt(mcFaderS.tfValue.text)/100, parseInt(mcFaderL.tfValue.text)/100);
mcFaderR.tfValue.text = Math.round(rgb.r);
mcFaderG.tfValue.text = Math.round(rgb.g);
mcFaderB.tfValue.text = Math.round(rgb.b);
break;
}
var R, G, B, H, S, L;
R = parseInt(mcFaderR.tfValue.text);
G = parseInt(mcFaderG.tfValue.text);
B = parseInt(mcFaderB.tfValue.text);
H = parseInt(mcFaderH.tfValue.text);
S = parseInt(mcFaderS.tfValue.text);
L = parseInt(mcFaderL.tfValue.text);
tfHex.text = toHex(R)+toHex(G)+toHex(B);
var arrRGBHSL = ["R", "G", "B", "H", "S", "L"];
for (var i = 0; i<arrRGBHSL.length; i++) {
with (eval("mcFader"+arrRGBHSL[i])) {
mcBox._x = Math.round(tfValue.text*94/limit)+13;
switch (flag) {
case "R" :
case "G" :
case "B" :
var beginColor = new Color(mcBegin);
var endColor = new Color(mcEnd);
var c0, c1;
switch (flag) {
case "R" :
c0 = G*256+B;
c1 = 255*256*256+G*256+B;
break;
case "G" :
c0 = R*256*256+B;
c1 = R*256*256+255*256+B;
break;
case "B" :
c0 = R*256*256+G*256;
c1 = R*256*256+G*256+255;
break;
}
beginColor.setRGB(c0);
endColor.setRGB(c1);
break;
case "H" :
var myColor = new Color(mcHue);
myColor.setTransform({ra:S, rb:(100-S)*1.275, ga:S, gb:(100-S)*1.275, ba:S, bb:(100-S)*1.275});
myColor = new Color(mcBg);
myColor.setRGB(L<50 ? 0x000000 : 0xFFFFFF);
mcBg._alpha = L<50 ? (50-L)*2 : (L-50)*2;
break;
case "S" :
var myColor = new Color(mcEnd);
var rgb = hslToRgb(H, 1, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
myColor = new Color(mcBg);
myColor.setRGB(L<50 ? 0x000000 : 0xFFFFFF);
mcBg._alpha = L<50 ? (50-L)*2 : (L-50)*2;
break;
case "L" :
var myColor = new Color(mcBg);
var rgb = hslToRgb(H, S/100, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
break;
}
}
}
mcBoardHS.mcPoint._x = Math.round(H*94/359)+1;
mcBoardHS.mcPoint._y = 95-Math.round(S*94/100);
mcLighteness.mcArrow._y = 95-Math.round(l*94/100);
var myColor = new Color(mcNewColor);
myColor.setRGB(R*256*256+G*256+B);
myColor = new Color(mcLighteness.mcBg);
var rgb = hslToRgb(H, S/100, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
myColor.setRGB("0x"+toHex(rgb.r)+toHex(rgb.g)+toHex(rgb.b));
}
updateAfterEvent();
}
function toHex(n) {
n = Math.round(n);
n = (n.toString(16).length<2 ? "0"+n.toString(16) : n.toString(16)).toUpperCase();
return n;
}
function hslToRgb(H, S, L) {
var p1, p2;
var rgb = new Array(3);
if (L<=0.5) {
p2 = L*(1+S);
} else {
p2 = L+S-(L*S);
}
p1 = 2*L-p2;
if (S == 0) {
rgb.r = L;
rgb.g = L;
rgb.b = L;
} else {
rgb.r = toRgb(p1, p2, H+120);
rgb.g = toRgb(p1, p2, H);
rgb.b = toRgb(p1, p2, H-120);
}
rgb.r *= 255;
rgb.g *= 255;
rgb.b *= 255;
return rgb;
}
function toRgb(q1, q2, hue) {
if (hue>360) {
hue = hue-360;
}
if (hue<0) {
hue = hue+360;
}
if (hue<60) {
return (q1+(q2-q1)*hue/60);
} else if (hue<180) {
return (q2);
} else if (hue<240) {
return (q1+(q2-q1)*(240-hue)/60);
} else {
return (q1);
}
}
function rgbToHsl(R, G, B) {
R /= 255;
G /= 255;
B /= 255;
var max, min, diff, r_dist, g_dist, b_dist;
var hsl = new Array(3);
max = Math.max(Math.max(R, G), B);
min = Math.min(Math.min(R, G), B);
diff = max-min;
hsl.l = (max+min)/2;
if (diff == 0) {
hsl.h = 0;
hsl.s = 0;
} else {
if (hsl.l<0.5) {
hsl.s = diff/(max+min);
} else {
hsl.s = diff/(2-max-min);
}
r_dist = (max-R)/diff;
g_dist = (max-G)/diff;
b_dist = (max-B)/diff;
if (R == max) {
hsl.h = b_dist-g_dist;
} else if (G == max) {
hsl.h = 2+r_dist-b_dist;
} else if (B == max) {
hsl.h = 4+g_dist-r_dist;
}
hsl.h *= 60;
if (hsl.h<0) {
hsl.h += 360;
}
if (hsl.h>=360) {
hsl.h -= 360;
}
}
return hsl;
}
var lightColor = 0xFFFFFF;
var darkColor = 0x9D9DA1;
var bgColor = 0xEEEEEE;
genColorPicker();
init("007f7f", 0);
function genColorPicker() {
var depth = 0;
var TF = new TextFormat();
TF.font = "Arial";
TF.size = 12;
this.beginFill(bgColor);
drawRect(this, 288, 160, 0, 0, .5, darkColor, lightColor);
this.endFill();
this.createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 116, 15, 5, 5);
this.createEmptyMovieClip("mcOldColor", depth++);
with (mcOldColor) {
_x = 5;
_y = 5;
beginFill(0x000000);
drawRect(mcOldColor, 58, 15, 0, 0, .5, 0x000000, 0x000000);
endFill();
}
this.createEmptyMovieClip("mcNewColor", depth++);
with (mcNewColor) {
_x = 63;
_y = 5;
beginFill(0xFF0000);
drawRect(mcNewColor, 58, 15, 0, 0, .5, 0xFF0000, 0xFF0000);
endFill();
}
drawRect(mcBorder, 62, 15, 158, 5);
this.createTextField("tfLabel", depth++, 131, 3, 27, 16);
with (tfLabel) {
selectable = false;
text = "Hex:";
setTextFormat(TF);
}
this.createTextField("tfHex", depth++, 158, 3, 62, 19);
with (tfHex) {
type = "input";
restrict = "0-9A-F";
maxChars = 6;
setNewTextFormat(TF);
tfHex.onKillFocus = hexChg;
}
this.createEmptyMovieClip("mcNone", depth++);
with (mcNone) {
_x = 252;
_y = 5;
beginFill(bgColor);
drawRect(mcNone, 15, 15, 0, 0, .5, darkColor, lightColor);
endFill();
beginFill(0xFFFFFF);
drawRect(mcNone, 9, 9, 3, 3);
endFill();
lineStyle(2, 0xFF0000);
moveTo(4, 11);
lineTo(11, 4);
drawRect(mcNone, 9, 9, 3, 3, .5, 0x000000, 0x000000);
mcNone.useHandCursor = false;
mcNone.onPress = function() {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcNone.onRelease = mcNone.onDragOut=function () {
with (_parent) {
var myColor = new Color(mcOldColor);
tfHex.text = ("000000"+myColor.getRGB().toString(16)).substr(-6);
hexChg();
tfHex.text = "";
drawRect(this, 15, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
this.createEmptyMovieClip("mcMode", depth++);
with (mcMode) {
_x = 268;
_y = 5;
drawRect(mcMode, 15, 15, 0, 0, .5, darkColor, lightColor);
mcMode.chgMode = function(mode) {
with (this) {
var arrMc = [_parent.mcMixer, _parent.mcSwatches];
for (var i = 0; i<arrMc.length; i++) {
arrMc[i]._visible = 0;
}
arrMc[Mode]._visible = 1;
switch (mode) {
case 0 :
colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
alphas = [100, 100, 100, 100, 100, 100, 100];
ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
matrix = {matrixType:"box", x:3, y:3, w:9, h:9, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
_parent.drawRect(this, 9, 9, 3, 3);
colors = [0x808080, 0x808080];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:3, y:3, w:9, h:9, r:0.5*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
_parent.drawRect(this, 9, 9, 3, 3, .5, 0x000000, 0x000000);
endFill();
break;
case 1 :
beginFill(0xFF0000);
_parent.drawRect(this, 4.5, 4.5, 3, 3, .5, 0x000000, 0x000000);
beginFill(0x00FF00);
_parent.drawRect(this, 4.5, 4.5, 7.5, 3, .5, 0x000000, 0x000000);
beginFill(0x0000FF);
_parent.drawRect(this, 4.5, 4.5, 3, 7.5, .5, 0x000000, 0x000000);
beginFill(0xFFFF00);
_parent.drawRect(this, 4.5, 4.5, 7.5, 7.5, .5, 0x000000, 0x000000);
endFill();
break;
}
}
};
mcMode.useHandCursor = false;
mcMode.onPress = function() {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcMode.onRelease = mcMode.onDragOut=function () {
with (_parent) {
drawRect(this, 15, 15, 0, 0, .5, darkColor, lightColor);
}
mode = mode == 0 ? 1 : 0;
chgMode(mode);
};
}
this.createEmptyMovieClip("mcMixer", depth++);
with (mcMixer) {
_visible = 0;
createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 96, 96, 5, 25);
createEmptyMovieClip("mcBoardHS", depth++);
with (mcBoardHS) {
_x = 5;
_y = 25;
var colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
var alphas = [100, 100, 100, 100, 100, 100, 100];
var ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
var matrix = {matrixType:"box", x:0, y:0, w:96, h:96, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBoardHS, 96, 96);
endFill();
colors = [0x808080, 0x808080];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:96, h:96, r:0.5*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBoardHS, 96, 96);
endFill();
createEmptyMovieClip("mcMask", 1);
mcMask.beginFill(0x000000);
drawRect(mcMask, 96, 96);
mcMask.endFill();
createEmptyMovieClip("mcPoint", 0);
with (mcPoint) {
_x = 1;
_y = 1;
lineStyle(.5, 0xFFFFFF);
moveTo(0, 1);
lineTo(0, 5);
moveTo(1, 0);
lineTo(5, 0);
moveTo(0, -1);
lineTo(0, -5);
moveTo(-1, 0);
lineTo(-5, 0);
setMask(mcMask);
}
mcBoardHS.useHandCursor = false;
mcBoardHS.onPress = function() {
mcPoint._x = _xmouse;
mcPoint._y = _ymouse;
Mouse.hide();
_parent._parent.adjustHsl();
this.onMouseMove = function() {
this.mcPoint._x = this._xmouse>0 && this._xmouse<96 ? this._xmouse : (this._xmouse<=0 ? 1 : 95);
this.mcPoint._y = this._ymouse>0 && this._ymouse<96 ? this._ymouse : (this._ymouse<=0 ? 1 : 95);
this._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
Mouse.show();
delete this.onMouseUp;
delete this.onMouseMove;
};
};
}
drawRect(mcBorder, 15, 96, 106, 25);
createEmptyMovieClip("mcLighteness", depth++);
with (mcLighteness) {
_x = 106;
_y = 25;
createEmptyMovieClip("mcBg", 0);
with (mcBg) {
beginFill(0x7F7F7F);
drawRect(mcBg, 15, 96, 0, 0, 0, 0x7F7F7F);
endFill();
}
createEmptyMovieClip("mcLighteness", 1);
with (mcLighteness) {
colors = [0xFFFFFF, 0xFFFFFF, 0x000000, 0x000000];
alphas = [100, 0, 0, 100];
ratios = [0x00, 0x7F, 0x80, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:15, h:96, r:.5*Math.PI};
mcLighteness.beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcLighteness, 15, 96);
endFill();
mcLighteness.useHandCursor = false;
mcLighteness.onPress = function() {
if (_ymouse>0 && _ymouse<96) {
_parent.mcArrow._y = _ymouse;
}
Mouse.hide();
_parent._parent._parent.adjustHsl();
this.onMouseMove = function() {
this._parent.mcArrow._y = this._ymouse>0 && this._ymouse<96 ? this._ymouse : (this._ymouse<=0 ? 1 : 95);
this._parent._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseUp;
delete this.onMouseMove;
Mouse.show();
};
};
}
createEmptyMovieClip("mcArrow", 2);
with (mcArrow) {
_x = 16;
_y = 1;
beginFill(0x000000);
lineTo(5, -4.5);
lineTo(5, 4.5);
lineTo(0, 0);
endFill();
mcArrow.useHandCursor = false;
mcArrow.onPress = function() {
offsetY = _ymouse;
_parent._parent._parent.adjustHsl();
this.onMouseMove = function() {
this.t = this._parent._ymouse-this.offsetY;
this._y = this.t>0 && this.t<96 ? this.t : (this.t<=0 ? 1 : 95);
this._parent._parent._parent.adjustHsl();
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseUp;
delete this.onMouseMove;
delete this.offsetY;
delete this.t;
};
};
}
}
var arrRGBHSL = ["R", "G", "B", "H", "S", "L"];
for (var i = 0; i<6; i++) {
var y = 25+i*16.5+(i>2 ? 2 : 0);
drawRect(mcBorder, 100, 12, 143, y);
drawRect(mcBorder, 25, 12, 248, y);
createEmptyMovieClip("mcFader"+arrRGBHSL[i], depth++);
eval("mcFader"+arrRGBHSL[i]).limit = arrRGBHSL[i] == "H" ? 359 : (arrRGBHSL[i] == "S" || arrRGBHSL[i] == "L" ? 100 : 255);
eval("mcFader"+arrRGBHSL[i]).flag = arrRGBHSL[i];
with (eval("mcFader"+arrRGBHSL[i])) {
_x = 131;
_y = y;
createTextField("tfLabel", 6, -2, -3, 15, 16);
with (tfLabel) {
selectable = false;
text = arrRGBHSL[i]+":";
setTextFormat(TF);
}
createTextField("tfValue", 5, 118, -3, 26, 16);
with (tfValue) {
type = "input";
text = 0;
restrict = "0-9";
maxChars = 3;
//setNewTextFormat(TF);
}
tfValue.onKillFocus = tfValue.onChanged=function () {
if (this.text == "") {
this.text = 0;
} else if (this.text>limit) {
this.text = limit;
} else {
this.text = parseInt(this.text);
}
_parent._parent.update(flag == "R" || flag == "G" || flag == "B" ? 0 : 1);
};
createEmptyMovieClip("mcBox", 10);
with (mcBox) {
_x = 13;
beginFill(0x000000);
drawRect(mcBox, 4, 12, 0, 0, 0, 0x000000, 0x000000);
endFill();
beginFill(0xFFFFFF);
drawRect(mcBox, 2, 12, 1, 0, 0, 0xFFFFFF, 0xFFFFFF);
endFill();
mcBox.useHandCursor = false;
mcBox.onPress = function() {
offsetX = _xmouse;
this.onMouseMove = function() {
this.t = this._parent._xmouse-this.offsetX;
this.t = this.t>12 && this.t<107 ? this.t : (this.t<=12 ? 13 : 107);
if (this.t>12 && this.t<107) {
this._x = this.t;
this._parent.tfValue.text = Math.round((this.t-13)*this._parent.limit/94);
this._parent._parent._parent.update(this._parent.flag == "R" || this._parent.flag == "G" || this._parent.flag == "B" ? 0 : 1);
}
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.onMouseMove;
delete this.onMouseMove;
delete this.t;
delete this.offsetX;
};
};
}
createEmptyMovieClip("mcUp", 3);
with (mcUp) {
_x = 145;
_y = -.5;
beginFill(bgColor);
drawRect(mcUp, 7, 6, 0, 0, .5, darkColor, lightColor);
beginFill(0x000000);
moveTo(3.5, .5);
lineTo(0.5, 5.5);
lineTo(6.5, 5.5);
lineTo(3.5, .5);
endFill();
mcUp.useHandCursor = false;
mcUp.onPress = function() {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, lightColor, darkColor);
}
iv0 = setInterval(prepare, 500);
up();
};
mcUp.prepare = function() {
iv1 = setInterval(up, 1);
clearInterval(iv0);
};
mcUp.up = function() {
if (_parent.tfValue.text<_parent.limit) {
_parent.tfValue.text++;
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
}
};
mcUp.onRelease = mcUp.onDragOut=function () {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, darkColor, lightColor);
}
clearInterval(iv0);
clearInterval(iv1);
};
}
createEmptyMovieClip("mcDown", 2);
with (mcDown) {
_x = 145;
_y = 6;
beginFill(bgColor);
drawRect(mcDown, 7, 6, 0, 0, .5, darkColor, lightColor);
beginFill(0x000000);
moveTo(3.5, 5.5);
lineTo(0.5, .5);
lineTo(6.5, .5);
lineTo(3.5, 5.5);
endFill();
mcDown.useHandCursor = false;
mcDown.onPress = function() {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, lightColor, darkColor);
}
iv0 = setInterval(prepare, 500);
down();
};
mcDown.prepare = function() {
iv1 = setInterval(down, 1);
clearInterval(iv0);
};
mcDown.down = function() {
if (_parent.tfValue.text>0) {
_parent.tfValue.text--;
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
}
};
mcDown.onRelease = mcDown.onDragOut=function () {
with (_parent._parent._parent) {
drawRect(this, 7, 6, 0, 0, .5, darkColor, lightColor);
}
clearInterval(iv0);
clearInterval(iv1);
};
}
createEmptyMovieClip("mcBg", 4);
with (mcBg) {
_x = 12;
beginFill(0xFFFFFF);
drawRect(mcBg, 100, 12);
endFill();
mcBg.useHandCursor = false;
mcBg.onPress = function() {
_parent.tfValue.text = Math.round(_xmouse*_parent.limit/100);
_parent._parent._parent.update(_parent.flag == "R" || _parent.flag == "G" || _parent.flag == "B" ? 0 : 1);
this.onMouseMove = function() {
this.t = this._xmouse>=0 && this._xmouse<=100 ? this._xmouse : (this._xmouse<0 ? 0 : 100);
this._parent.tfValue.text = Math.round(this.t*this._parent.limit/100);
this._parent._parent._parent.update(this._parent.flag == "R" || this._parent.flag == "G" || this._parent.flag == "B" ? 0 : 1);
updateAfterEvent();
};
this.onMouseUp = function() {
delete this.t;
delete this.onMouseUp;
delete this.onMouseMove;
};
};
}
if (flag == "L") {
createEmptyMovieClip("mcLighteness", 7);
with (mcLighteness) {
_x = 12;
colors = [0xFFFFFF, 0xFFFFFF, 0x000000, 0x000000];
alphas = [100, 0, 0, 100];
ratios = [0x00, 0x7F, 0x80, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:96, h:12, r:-1*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcLighteness, 100, 12);
endFill();
}
} else if (flag == "H") {
createEmptyMovieClip("mcHue", 7);
with (mcHue) {
_x = 12;
colors = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000];
alphas = [100, 100, 100, 100, 100, 100, 100];
ratios = [0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:100, h:10, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcHue, 100, 12);
endFill();
swapDepths(mcBg);
}
} else if (flag == "R" || flag == "G" || flag == "B" || flag == "S") {
createEmptyMovieClip("mcBegin", 8);
with (mcBegin) {
colors = [flag == "S" ? 0x808080 : 0x000000, flag == "S" ? 0x808080 : 0x000000];
alphas = [100, 0];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:12, y:0, w:100, h:12, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcBegin, 100, 12, 12);
endFill();
}
createEmptyMovieClip("mcEnd", 7);
with (mcEnd) {
colors = [0x000000, 0x000000];
alphas = [0, 100];
ratios = [0x00, 0xFF];
matrix = {matrixType:"box", x:12, y:0, w:100, h:12, r:0};
beginGradientFill("linear", colors, alphas, ratios, matrix);
drawRect(mcEnd, 100, 12, 12);
endFill();
}
if (flag == "S") {
mcBg.swapDepths(9);
}
}
}
}
}
this.createEmptyMovieClip("mcSwatches", depth++);
with (mcSwatches) {
_visible = 0;
var arrColor = new Array();
var arrNum = new Array("00", "33", "66", "99", "CC", "FF");
var arrBaseColor = new Array("000000", "333333", "666666", "999999", "CCCCCC", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "00FFFF", "FF00FF");
for (var i = 0; i<12; i++) {
arrColor[arrColor.length] = arrBaseColor[i];
for (var j = 0; j<18; j++) {
arrColor[arrColor.length] = arrNum[Math.floor(i/6)*3+Math.floor(j/6)]+arrNum[j%6]+arrNum[i%6];
}
arrColor[arrColor.length] = "000000";
for (var j = 0; j<15; j++) {
var t = (Math.round((1-(i*15+j)/179)*255)).toString(16);
t = t.length>1 ? t : "0"+t;
t = t.toUpperCase();
arrColor[arrColor.length] = t+t+t;
}
}
var cols = 35;
for (var i = 0; i<Math.ceil(arrColor.length/cols); i++) {
for (var j = 0; j<cols; j++) {
var t = i*cols+j<arrColor.length ? arrColor[i*cols+j] : "000000";
createEmptyMovieClip("mc"+t+i+j, depth++);
var mc = eval("mc"+t+i+j);
with (mc) {
_y = 25+i*8;
_x = (j>19 ? 3 : 5)+j*8;
beginFill(parseInt(t, 16));
drawRect(mc, (j == 19 ? 6 : 8), 8, 0, 0, .5, 0x0000000, 0x000000);
endFill();
}
mc.onRollOver = function() {
with (_parent) {
this.t = tfHex.text;
tfHex.text = this._name.substr(2, 6);
hexChg();
}
with (mcBorder) {
_visible = 1;
_x = this._x;
_y = this._y;
_width = this._width;
_height = this._height;
}
};
mc.onPress = function() {
_parent.tfHex.text = this.t=this._name.substr(2, 6);
};
mc.onRollOut = mc.onDragOut=function () {
_parent.tfHex.text = this.t;
_parent.hexChg();
mcBorder._visible = 0;
};
}
}
createEmptyMovieClip("mcBorder", 1000);
drawRect(mcBorder, 8, 8, 0, 0, .5, 0xFFFFFF, 0xFFFFFF);
mcBorder._visible = 0;
}
this.createTextField("tfCopyright0", depth++, 6, 141, 283, 20);
with (tfCopyright0) {
selectable = false;
html = true;
htmlText = "<p align=/"right/"><font size=/"10/" face=/"Arial/" color=/"#FFFFFF/"><a href=/" http://www.nlimi.com/" target=/"_blank/">Copyright (c) Afeila Studio All rights reserved.</p>";
}
this.createTextField("tfCopyright", depth++, 5, 140, 283, 20);
with (tfCopyright) {
selectable = false;
html = true;
htmlText = "<p align=/"right/"><font size=/"10/" face=/"Arial/" color=/"#999999/">Copyright (c) Afeila Studio All rights reserved.</p>";
}
this.createEmptyMovieClip("mcReset", depth++);
with (mcReset) {
_x = 5;
_y = 126;
beginFill(bgColor);
drawRect(mcReset, 89, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 89, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">Reset</p>";
}
mcReset.useHandCursor = false;
mcReset.onPress = function() {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcReset.onRelease = mcReset.onDragOut=function () {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, darkColor, lightColor);
var myColor = new Color(mcOldColor);
tfHex.text = ("000000"+myColor.getRGB().toString(16)).substr(-6);
hexChg();
}
};
}
this.createEmptyMovieClip("mcOK", depth++);
with (mcOK) {
_x = 99;
_y = 126;
beginFill(bgColor);
drawRect(mcOK, 90, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 90, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">OK</p>";
}
mcOK.useHandCursor = false;
mcOK.onPress = function() {
with (_parent) {
drawRect(this, 90, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcOK.onRelease = mcOK.onDragOut=function () {
with (_parent) {
drawRect(this, 90, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
this.createEmptyMovieClip("mcCancel", depth++);
with (mcCancel) {
_x = 194;
_y = 126;
beginFill(bgColor);
drawRect(mcCancel, 89, 15, 0, 0, .5, darkColor, lightColor);
endFill();
createTextField("tfLabel", 0, 0, -2, 89, 20);
with (tfLabel) {
selectable = false;
html = true;
htmlText = "<p align=/"center/"><font face=/"Arial/">Cancel</p>";
}
mcCancel.useHandCursor = false;
mcCancel.onPress = function() {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, lightColor, darkColor);
}
};
mcCancel.onRelease = mcCancel.onDragOut=function () {
with (_parent) {
drawRect(this, 89, 15, 0, 0, .5, darkColor, lightColor);
}
};
}
}
function init(initColor, mode) {
tfHex.text = initColor;
hexChg();
mode = mode != null ? mode : 0;
mcMode.mode = mode;
mcMode.chgMode();
var myColor = new Color(mcOldColor);
myColor.setRGB(parseInt(tfHex.text, 16));
}
function hexChg() {
tfHex.text += "000000".substr(0, 6-tfHex.text.length);
with (mcMixer) {
mcFaderR.tfValue.text = parseInt(tfHex.text.substr(0, 2), 16);
mcFaderG.tfValue.text = parseInt(tfHex.text.substr(2, 2), 16);
mcFaderB.tfValue.text = parseInt(tfHex.text.substr(4, 2), 16);
update(0);
}
}
function drawRect(mc, w, h, oX, oY, lW, c0, c1) {
oX = oX != null ? oX : 0;
oY = oY != null ? oY : 0;
c0 = c0 != null ? c0 : lightColor;
c1 = c1 != null ? c1 : darkColor;
with (mc) {
moveTo(w+oX, oY);
lineStyle(lW != null ? lW : .5, c0);
lineTo(w+oX, h+oY);
lineTo(oX, h+oY);
lineStyle(lW != null ? lW : .5, c1);
lineTo(oX, oY);
lineTo(w+oX, oY);
}
}
function adjustHsl() {
with (mcMixer) {
var h = (mcBoardHS.mcPoint._x-1)*359/94;
var s = (95-mcBoardHS.mcPoint._y)*100/94;
var v = (95-mcLighteness.mcArrow._y)*100/94;
mcFaderH.tfValue.text = Math.round(h);
mcFaderS.tfValue.text = Math.round(s);
mcFaderL.tfValue.text = Math.round(v);
}
update(1);
}
function update(mode) {
with (mcMixer) {
switch (mode) {
case 0 :
var hsl = rgbToHsl(parseInt(mcFaderR.tfValue.text), parseInt(mcFaderG.tfValue.text), parseInt(mcFaderB.tfValue.text));
mcFaderH.tfValue.text = Math.round(hsl.h);
mcFaderS.tfValue.text = Math.round(hsl.s*100);
mcFaderL.tfValue.text = Math.round(hsl.l*100);
break;
case 1 :
var rgb = hslToRgb(parseInt(mcFaderH.tfValue.text), parseInt(mcFaderS.tfValue.text)/100, parseInt(mcFaderL.tfValue.text)/100);
mcFaderR.tfValue.text = Math.round(rgb.r);
mcFaderG.tfValue.text = Math.round(rgb.g);
mcFaderB.tfValue.text = Math.round(rgb.b);
break;
}
var R, G, B, H, S, L;
R = parseInt(mcFaderR.tfValue.text);
G = parseInt(mcFaderG.tfValue.text);
B = parseInt(mcFaderB.tfValue.text);
H = parseInt(mcFaderH.tfValue.text);
S = parseInt(mcFaderS.tfValue.text);
L = parseInt(mcFaderL.tfValue.text);
tfHex.text = toHex(R)+toHex(G)+toHex(B);
var arrRGBHSL = ["R", "G", "B", "H", "S", "L"];
for (var i = 0; i<arrRGBHSL.length; i++) {
with (eval("mcFader"+arrRGBHSL[i])) {
mcBox._x = Math.round(tfValue.text*94/limit)+13;
switch (flag) {
case "R" :
case "G" :
case "B" :
var beginColor = new Color(mcBegin);
var endColor = new Color(mcEnd);
var c0, c1;
switch (flag) {
case "R" :
c0 = G*256+B;
c1 = 255*256*256+G*256+B;
break;
case "G" :
c0 = R*256*256+B;
c1 = R*256*256+255*256+B;
break;
case "B" :
c0 = R*256*256+G*256;
c1 = R*256*256+G*256+255;
break;
}
beginColor.setRGB(c0);
endColor.setRGB(c1);
break;
case "H" :
var myColor = new Color(mcHue);
myColor.setTransform({ra:S, rb:(100-S)*1.275, ga:S, gb:(100-S)*1.275, ba:S, bb:(100-S)*1.275});
myColor = new Color(mcBg);
myColor.setRGB(L<50 ? 0x000000 : 0xFFFFFF);
mcBg._alpha = L<50 ? (50-L)*2 : (L-50)*2;
break;
case "S" :
var myColor = new Color(mcEnd);
var rgb = hslToRgb(H, 1, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
myColor = new Color(mcBg);
myColor.setRGB(L<50 ? 0x000000 : 0xFFFFFF);
mcBg._alpha = L<50 ? (50-L)*2 : (L-50)*2;
break;
case "L" :
var myColor = new Color(mcBg);
var rgb = hslToRgb(H, S/100, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
break;
}
}
}
mcBoardHS.mcPoint._x = Math.round(H*94/359)+1;
mcBoardHS.mcPoint._y = 95-Math.round(S*94/100);
mcLighteness.mcArrow._y = 95-Math.round(l*94/100);
var myColor = new Color(mcNewColor);
myColor.setRGB(R*256*256+G*256+B);
myColor = new Color(mcLighteness.mcBg);
var rgb = hslToRgb(H, S/100, .5);
myColor.setRGB(Math.round(rgb.r)*256*256+Math.round(rgb.g)*256+Math.round(rgb.b));
myColor.setRGB("0x"+toHex(rgb.r)+toHex(rgb.g)+toHex(rgb.b));
}
updateAfterEvent();
}
function toHex(n) {
n = Math.round(n);
n = (n.toString(16).length<2 ? "0"+n.toString(16) : n.toString(16)).toUpperCase();
return n;
}
function hslToRgb(H, S, L) {
var p1, p2;
var rgb = new Array(3);
if (L<=0.5) {
p2 = L*(1+S);
} else {
p2 = L+S-(L*S);
}
p1 = 2*L-p2;
if (S == 0) {
rgb.r = L;
rgb.g = L;
rgb.b = L;
} else {
rgb.r = toRgb(p1, p2, H+120);
rgb.g = toRgb(p1, p2, H);
rgb.b = toRgb(p1, p2, H-120);
}
rgb.r *= 255;
rgb.g *= 255;
rgb.b *= 255;
return rgb;
}
function toRgb(q1, q2, hue) {
if (hue>360) {
hue = hue-360;
}
if (hue<0) {
hue = hue+360;
}
if (hue<60) {
return (q1+(q2-q1)*hue/60);
} else if (hue<180) {
return (q2);
} else if (hue<240) {
return (q1+(q2-q1)*(240-hue)/60);
} else {
return (q1);
}
}
function rgbToHsl(R, G, B) {
R /= 255;
G /= 255;
B /= 255;
var max, min, diff, r_dist, g_dist, b_dist;
var hsl = new Array(3);
max = Math.max(Math.max(R, G), B);
min = Math.min(Math.min(R, G), B);
diff = max-min;
hsl.l = (max+min)/2;
if (diff == 0) {
hsl.h = 0;
hsl.s = 0;
} else {
if (hsl.l<0.5) {
hsl.s = diff/(max+min);
} else {
hsl.s = diff/(2-max-min);
}
r_dist = (max-R)/diff;
g_dist = (max-G)/diff;
b_dist = (max-B)/diff;
if (R == max) {
hsl.h = b_dist-g_dist;
} else if (G == max) {
hsl.h = 2+r_dist-b_dist;
} else if (B == max) {
hsl.h = 4+g_dist-r_dist;
}
hsl.h *= 60;
if (hsl.h<0) {
hsl.h += 360;
}
if (hsl.h>=360) {
hsl.h -= 360;
}
}
return hsl;
}
此博客展示了Flash颜色选择器的代码实现。定义了多种颜色变量,创建了多个空影片剪辑用于显示颜色、输入十六进制颜色值等。包含生成颜色选择器、绘制矩形、颜色模式切换等功能函数,还实现了RGB与HSL颜色空间的转换。
3097

被折叠的 条评论
为什么被折叠?



