In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

カラーピッカーのアレ

Get Adobe Flash player
by taiga 10 Feb 2009
package {
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.text.TextField;
    [SWF (backgroundColor='0')]
    public class ColorPicker extends Sprite {
        private var textField:TextField;
        private var colorList:Array = [0, 3355443, 6710886, 10066329, 13421772, 16777215, 16711680, 65280, 255, 16776960, 65535, 16711935], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 51, 102, 153, 204, 255, 10027008, 10027059, 10027110, 10027161, 10027212, 10027263], [13056, 13107, 13158, 13209, 13260, 13311, 10040064, 10040115, 10040166, 10040217, 10040268, 10040319], [26112, 26163, 26214, 26265, 26316, 26367, 10053120, 10053171, 10053222, 10053273, 10053324, 10053375], [39168, 39219, 39270, 39321, 39372, 39423, 10066176, 10066227, 10066278, 10066329, 10066380, 10066431], [52224, 52275, 52326, 52377, 52428, 52479, 10079232, 10079283, 10079334, 10079385, 10079436, 10079487], [65280, 65331, 65382, 65433, 65484, 65535, 10092288, 10092339, 10092390, 10092441, 10092492, 10092543], [3342336, 3342387, 3342438, 3342489, 3342540, 3342591, 13369344, 13369395, 13369446, 13369497, 13369548, 13369599], [3355392, 3355443, 3355494, 3355545, 3355596, 3355647, 13382400, 13382451, 13382502, 13382553, 13382604, 13382655], [3368448, 3368499, 3368550, 3368601, 3368652, 3368703, 13395456, 13395507, 13395558, 13395609, 13395660, 13395711], [3381504, 3381555, 3381606, 3381657, 3381708, 3381759, 13408512, 13408563, 13408614, 13408665, 13408716, 13408767], [3394560, 3394611, 3394662, 3394713, 3394764, 3394815, 13421568, 13421619, 13421670, 13421721, 13421772, 13421823], [3407616, 3407667, 3407718, 3407769, 3407820, 3407871, 13434624, 13434675, 13434726, 13434777, 13434828, 13434879], [6684672, 6684723, 6684774, 6684825, 6684876, 6684927, 16711680, 16711731, 16711782, 16711833, 16711884, 16711935], [6697728, 6697779, 6697830, 6697881, 6697932, 6697983, 16724736, 16724787, 16724838, 16724889, 16724940, 16724991], [6710784, 6710835, 6710886, 6710937, 6710988, 6711039, 16737792, 16737843, 16737894, 16737945, 16737996, 16738047], [6723840, 6723891, 6723942, 6723993, 6724044, 6724095, 16750848, 16750899, 16750950, 16751001, 16751052, 16751103], [6736896, 6736947, 6736998, 6737049, 6737100, 6737151, 16763904, 16763955, 16764006, 16764057, 16764108, 16764159], [6749952, 6750003, 6750054, 6750105, 6750156, 6750207, 16776960, 16777011, 16777062, 16777113, 16777164, 16777215], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
        public function ColorPicker() {
            super();
            var s:ColorSquare;
            var i:int;
            var j:int;
            for(i = 0; i < 21; i++) {
                for(j = 0; j < 12; j++) {
                    s = new ColorSquare();
                    s.x = (i * 11) + 3;
                    s.y = (j * 11) + 26;
                    s.color = colorList[i][j];
                    s.addEventListener(MouseEvent.ROLL_OVER, colorSquareRollOverHandler);
                    addChild(s);
                }
            }
            textField           = new TextField();
            textField.y         = 0;
            textField.width     = 200;
            textField.height    = 20;
            textField.textColor = 0xffffff;
            textField.text      = "#";
            addChild(textField);
        }
        private function colorSquareRollOverHandler(event:MouseEvent):void {
            var target:ColorSquare = event.currentTarget as ColorSquare;
            textField.text = target.colorString;
        }
    }
}
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
import flash.display.Shape;
class ColorSquare extends Sprite {
    private var _color           :uint;
    private var _colorString     :String;
    private var _colorShape      :Shape;
    private var _backgroundShape :Shape;
    public function get colorString():String {
        return getFigure(_colorString);
    }
    public function get color():uint {
        return _color;
    }
    public function set color(v:uint):void {
        _color       = v;
        _colorString = v.toString(16);
        var r:uint = (v >> 16) & 0xff;
        var g:uint = (v >> 8) & 0xff;
        var b:uint = v & 0xff;
        _colorShape.transform.colorTransform = new ColorTransform(0,0,0,1,r,g,b);
    }
    public function ColorSquare():void {
        super();
        _backgroundShape = new Shape();
        _backgroundShape.graphics.beginFill(0xffffff);
        _backgroundShape.graphics.drawRect(0,0,12,12);
        _backgroundShape.graphics.endFill();
        _backgroundShape.visible = false;

        _colorShape      = new Shape();
        _colorShape.graphics.beginFill(0xffffff);
        _colorShape.graphics.drawRect(1,1,10,10);
        _colorShape.graphics.endFill();

        addChild(_backgroundShape);
        addChild(_colorShape);

        addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent):void {_backgroundShape.visible = true});
        addEventListener(MouseEvent.ROLL_OUT,  function(e:MouseEvent):void {_backgroundShape.visible = false});

    }
    private function getFigure(s:String):String {
        var i  :int;
        var l  :int = s.length;
        var sp :String = "#";
        if (6 > l) {
            for (i = 0; i < 6 - l; i++) {
                sp += "0";
            }
            sp += s;
            return sp;
        }
        else {
            return String("#" + s);
        }
    }
}