поюзайте портотипчик
/*
- colour patterns' generation principles;
- some functionality of colour patterns;
- usage examples.
In order to preview, copy the script
into the frame of new FLA (MX only)
then press CTRL+ENTER
enjoy.
If you have any questions, contact me dembicki@narod.ru
*/
MovieClip.prototype.mouseHitTest = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
return true;
}
};
MovieClip.prototype.colorised = function(flag) {
if (flag) {
this.onMouseDown = function() {
if (this.mouseHitTest()) {
trace("target is "+this);
Mouse.color_target = this;
} else if (Mouse.color_target == this) {
if (!Mouse.color_bar.mouseHitTest()) {
trace("Target removed: \r\t"+Mouse.color_bar);
Mouse.color_target = null;
}
}
};
}
};
// © Ivan Dembicki dembicki@narod.ru
MovieClip.prototype.popUp = function() {
var i = 0;
var arrMc = new Array();
for (var mc in this._parent) {
var m = this._parent[mc];
if (!i) {
if (this == m) {
return;
}
}
if (typeof m == "movieclip") {
arrMc.push(m);
if (m._name == _name) {
break;
}
i++;
}
}
for (i; i>0; i--) {
this.swapDepths(arrMc[i-1]);
}
};
// © Ivan Dembicki dembicki@narod.ru
MovieClip.prototype.createPattern = function(wdth) {
this.createEmptyMovieClip("pattern", 1);
var mc = this["pattern"];
mc.createEmptyMovieClip("controller", 1);
Mouse.color_bar = mc;
Mouse.color_number = 0xFFFFFF;
with (mc.controller) {
beginFill(0xFFFFFF);
moveTo(1, 1);
lineTo(14, 1);
lineTo(14, 12);
lineTo(1, 12);
lineTo(1, 1);
endFill();
}
//
mc.createEmptyMovieClip("face", 2);
with (mc.face) {
beginFill(0xD8D0C8);
lineStyle(1, 0x808080, 90);
moveTo(0, 0);
lineTo(15, 0);
lineTo(15, 13);
lineStyle(1, 0xFFFFFF, 90);
lineTo(0, 13);
lineTo(0, 0);
//
lineStyle(1, 0xFFFFFF, 90);
moveTo(2, 2);
lineTo(8.5, 2);
lineTo(8.5, 4);
lineTo(13, 4);
lineTo(13, 11);
lineStyle(1, 0x808080, 90);
lineTo(2, 11);
lineTo(2, 2);
endFill();
// triangle
beginFill(0x000000);
lineStyle(1, 0, 100);
moveTo(10.5, 2.7);
lineTo(12, 1.2);
lineTo(13.5, 2.7);
endFill();
//
}
// mouse up to updated !!!
mc.controller.onMouseUp = function() {
this._parent._parent.popUp();
if (this._parent.safePattern == null) {
if (this.mouseHitTest()) {
// trace("safe pattern created");
this._parent.createSafePattern("safePattern", 0, wdth/36, 20, 30);
}
} else {
// trace("safe pattern removed");
this._parent.safePattern.removeMovieClip();
}
};
// ***** create SafePattern *****
mc.createSafePattern = function(name, depth, sq, x, y) {
//trace(name+" created in "+this);
// name = pattern mc name
// depth = pattern mc depth
// sq = site of one color square
// x, y = position of pattern
this.createEmptyMovieClip(name, depth);
!sq ? sq=10 : "";
var mc = this[name];
// mc.popUp();
mc._x = x;
mc._y = y;
var z;
//
with (mc) {
beginFill(0xFFFFFF);
moveTo(0, 0);
lineTo(sq*36, 0);
lineTo(sq*36, sq*6);
lineTo(0, sq*6);
lineTo(0, 0);
endFill();
}
//
for (var i = 0; i<6; i++) {
var clr0 = i*0x330000;
for (var ii = 0; ii<6; ii++) {
var clr1 = ii*0x003300;
var x = sq*z++;
for (var iii = 0; iii<6; iii++) {
var clr2 = iii*0x000033;
var y = iii*sq;
var clr = clr0+clr1+clr2;
//
with (mc) {
beginFill(clr);
moveTo(x, y);
lineTo(x+sq-.5, y);
lineTo(x+sq-.5, y+sq-.5);
lineTo(x, y+sq-.5);
lineTo(x, y);
endFill();
}
//
}
}
}
// draw window
with (mc) {
//
lineStyle(1, 0x808080, 100);
beginFill(0xD4D0C8);
moveTo(0, 0);
lineTo(0, -sq*2);
lineTo(sq*36, -sq*2);
lineStyle(1, 0x666666, 100);
lineTo(sq*36, 0);
lineTo(0, 0);
endFill();
moveTo(0, sq*6);
lineTo(sq*36, sq*6);
lineTo(sq*36, sq*6);
lineTo(sq*36, 0);
lineStyle(1, 0x808080, 100);
moveTo(0, 0);
lineTo(0, sq*6);
//
mc.createEmptyMovieClip("hex_mc", 1);
with (mc.hex_mc) {
createTextField("hex_string", 1, 0, 0, 60, 18);
hex_string.background = true;
if (this.controller.selected_color != null) {
hex_string.text = this.controller.selected_color;
} else {
hex_string.text = " #FFFFFF";
}
_x = sq;
_y = -sq*1.6;
_xscale = mc.hex_mc._yscale=100*(sq/15);
}
//
// ***** pattern get color *****
mc.patternGetColor = function() {
var sq = (this._width-2)/36;
if (this.patternHitTest()) {
var clr = Math.floor(this._ymouse/sq)*0x000033+(Math.floor(this._xmouse/sq)%6)*0x003300+clr3+Math.floor(this._xmouse/sq/6)*0x330000;
this.hex_mc.hex_string.text = clr.toString(16);
with (this.hex_mc.hex_string) {
while (length<6) {
text = "0"+text;
}
text = " #"+text.toUpperCase();
}
return clr;
}
};
// end get color //
//
// ***** pattern hit test *****
mc.patternHitTest = function() {
var sq = (this._width-2)/36;
if (this._xmouse>0) {
if (this._ymouse>0) {
if (this._xmouse<sq*36) {
if (this._ymouse<sq*6) {
return true;
}
}
}
}
this.hex_mc.hex_string.text = this._parent.controller.selected_color != null ? this._parent.controller.selected_color : " #FFFFFF";
};
// end pattern hit test //
mc.onMouseMove = function() {
// this == safe pattern
if (this.patternHitTest()) {
new Color(Mouse.color_target).setRGB(this.patternGetColor());
} else if (this._parent.controller.mouseHitTest()) {
new Color(Mouse.color_target).setRGB(Mouse.color_number);
} else {
//
}
};
//////////// end of mouse move //////////////
/// mouse up to removed!!!!!
mc.onMouseUp = function() {
if (this.patternHitTest()) {
var cnt = this._parent.controller;
Mouse.color_number = this.patternGetColor();
cnt.selected_color = this.hex_mc.hex_string.text;
new Color(cnt).setRGB(Mouse.color_number);
new Color(Mouse.color_target).setRGB(Mouse.color_number);
}
};
//////// end of mouse up //////////
}
};
// End create SafePattern //
};
MovieClip.prototype.drawColorbar = function(wdth, hght) {
this.createEmptyMovieClip("colorbar_rgb", 99);
this.colorbar_rgb.onMouseMove = function() {
new Color(Mouse.color_target).setTransform(this.fncDropper());
};
this.colorbar_rgb.fncDropper = function() {
if (this.mouseHitTest()) {
var clr = new Object();
var x = this._xmouse/this._width*6;
var x_up = x-Math.floor(x);
var x_dw = 1-x_up;
if (x<1) {
clr.rb = 255;
clr.gb = 255*x_up;
clr.bb = 0;
} else if (x<2) {
clr.rb = 255*x_dw;
clr.gb = 255;
clr.bb = 0;
} else if (x<3) {
clr.rb = 0;
clr.gb = 255;
clr.bb = 255*x_up;
} else if (x<4) {
clr.rb = 0;
clr.gb = 255*x_dw;
clr.bb = 255;
} else if (x<5) {
clr.rb = 255*x_up;
clr.gb = 0;
clr.bb = 255;
} else if (x<6) {
clr.rb = 255;
clr.gb = 0;
clr.bb = 255*x_dw;
}
var y = (-this._ymouse+this._height/2)/this._height*2;
if (y>0) {
clr.rb += (255-clr.rb)*y;
clr.gb += (255-clr.gb)*y;
clr.bb += (255-clr.bb)*y;
} else if (y<0) {
clr.rb += clr.rb*y;
clr.gb += clr.gb*y;
clr.bb += clr.bb*y;
}
return clr;
}
};
//////////////////////
this.colorbar_rgb.createEmptyMovieClip("rgb", 1);
colors = [0xff0000, 0xffff00, 0x00ff00, 0x00ffff, 0x0000ff, 0xff00ff, 0xff0000];
alphas = [100, 100, 100, 100, 100, 100, 100];
pt = 255/6;
ratios = [0, pt*1, pt*2, pt*3, pt*4, pt*5, 255];
matrix = {matrixType:"box", x:0, y:0, w:wdth, h:hght/2, r:0};
with (this.colorbar_rgb.rgb) {
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveto(0, 0);
lineto(0, hght);
lineto(wdth, hght);
lineto(wdth, 0);
lineto(0, 0);
endFill();
}
this.colorbar_rgb.createEmptyMovieClip("w_0", 2);
colors = [0xffffff, 0xffffff];
alphas = [100, 0];
ratios = [0, 255];
matrix = {matrixType:"box", x:0, y:0, w:hght/2, h:hght/2, r:1.5707963267949};
with (this.colorbar_rgb.w_0) {
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveto(0, 0);
lineto(0, hght/2);
lineto(wdth, hght/2);
lineto(wdth, 0);
lineto(0, 0);
endFill();
}
colors = [0x000000, 0x000000];
alphas = [0, 100];
ratios = [0, 255];
rot = 90*Math.PI/180;
matrix = {matrixType:"box", x:0, y:hght/2, w:hght/2, h:hght/2, r:rot};
with (this.colorbar_rgb.w_0) {
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveto(0, hght/2);
lineto(0, hght);
lineto(wdth, hght);
lineto(wdth, hght/2);
lineto(0, hght/2);
endFill();
}
};
/// TEST ///
_root.createEmptyMovieClip("bar", 1).drawColorbar(280, 90);
_root.createEmptyMovieClip("bar1", 5).drawColorbar(300, 200);
_root.bar1._x = 300;
_root.createEmptyMovieClip("patt1", 7).createPattern();
_root.patt1._y = 300;
_root.createEmptyMovieClip("mc", 3).colorised(true);
with (_root.mc) {
_x = 0;
_y = 0;
beginFill(0x000000, 100);
lineStyle(0, 0, 100);
moveTo(100, 100);
lineTo(200, 100);
lineTo(200, 200);
lineTo(100, 200);
lineTo(100, 100);
endFill();
}
_root.createEmptyMovieClip("mc1", 4).colorised(true);
with (_root.mc1) {
_x = 200;
_y = 200;
beginFill(0x000000, 100);
lineStyle(0, 0, 100);
moveTo(100, 100);
lineTo(200, 100);
lineTo(200, 200);
lineTo(100, 200);
lineTo(100, 100);
endFill();
}
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.