Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript (http://www.flasher.ru/forum/forumdisplay.php?f=5)
-   -   Как открыть windows окно выбора цвета ??? (http://www.flasher.ru/forum/showthread.php?t=51663)

Ламер_Флаша 19.11.2003 03:47

Как открыть windows окно выбора цвета ???
 
Можно как-нибудь из мува FlashMX вызвать стандартное виндовое окно выбора цвета с последующуй передачей выбранного цвета обратно во flash мувик??

Если нет, то каким образом проще и удобнее всего реализовать эту функцию ??

Заранее благодарен.

gustera 19.11.2003 14:58

Есть Color Picker exension здесь .

Ламер_Флаша 19.11.2003 15:53

Спасибо. Закачал кучу *.mxp ... что с ними делать? как их приаттачить? :confused:

gustera 19.11.2003 16:12

:D я тоже не очень разобрался в етих extensions и начал сам делать. сегодня или завтра должен быть готов. если хочеш могу кинуть суда.

gustera 19.11.2003 16:38

Вложений: 1
можно и как в етом примере, но не очень user friendly ;)

Ламер_Флаша 19.11.2003 21:02

http://forum.ixbt.com/insane.gif
Это просто поле для ввода номера цвета... а нужен дружественный пользовательский диалог, выглядящий наподобие виндового окна выбора цвета (тоесть палитра, двигающиеся указатели, цвет в числах)... где бы такое надыбать???
:confused:

gustera 20.11.2003 13:51

да, но ето самый простой вариант
вот что я нашел:
http://www.flashkit.com/movies/Inter...1312/index.php

скомбинируй ету палету с мойм творением и получится то что надо. Замечания по моему творению НЕ принимаются. Знаю что можно и лучше, но на етот момент ето мне годится, а и времени нет. Юзай на здоровье! :D ;) :cool:

gustera 20.11.2003 13:54

Вложений: 1
а вот и творение

opex 20.11.2003 19:52

поюзайте портотипчик

Код:

/*
- 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();
}


Ламер_Флаша 21.11.2003 02:07

gustera
Спасибо :)

opex
Типа длинновато и как-то непонятно... ну да всё равно спасибо, завтра постараюсь разобраться "шо це таке" :)


А вообще на сайте макромедии нашел несколько очень приличных mxp с color picker. Два минуса: 1 - занимают откомпилированные мувы более 30Кб за одну палитру, блин :( 2 - загружают проц AthlonXP 1800+ на 70-85%... ну куда это годится?! :(

Видимо, придётся опять разжиться собственным хэндмейдом :D


===========================
Повторю первоначальный вопрос:
Может все же можно как-нибудь открывать windows окно-палитру с возвратом из неё значений???


Часовой пояс GMT +4, время: 15:56.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.