I think it really is in the tiny difference in color values.
(if you want the "glow" rounded as on
http://www.jooria.com/Drawing-Glossy-Button-a138.html, you could use a
Bezier curve).
I did this and added a little bevel.

Regards
Cor
//-----------

package {
        import flash.display.Sprite;

        public class SimpleButton_Cor extends Sprite {
                public function SimpleButton_Cor () {
                        var button:CustomSimpleButton = new
CustomSimpleButton();
                        button.x = button.y = 100;
                        addChild (button);
                }
        }
}

import flash.display.*;
import flash.filters.*;
import flash.geom.*;

class CustomSimpleButton extends SimpleButton {
        private var overColor:uint = 0xFFCC00;
        private var downColor:uint = 0xFF6666;
        private var upColor:uint = 0x00CCFF;
        private var size:uint = 80;

        public function CustomSimpleButton () {
                downState = new ButtonDisplayState(downColor,size);
                overState = new ButtonDisplayState(overColor,size);
                upState = new ButtonDisplayState(upColor,size);
                hitTestState = upState;
                useHandCursor = true;
        }
}

class ButtonDisplayState extends Shape {
        private var bgColor:uint;
        private var size:uint;

        public static const SHADOW:GlowFilter = new
GlowFilter(0x000000,1.0,4,4,1,1,false,false);
        public static const GLOW:GlowFilter = new
GlowFilter(0xFFFFFF,0.8,40,40,1,1,true,false);
        public static const BEVEL:BevelFilter = new
BevelFilter(2,45,0xFFFFFF,.8,0x000000,.8,2,2,3,3,"inner",false);

        public function ButtonDisplayState (bgColor:uint, size:uint) {
                this.bgColor = bgColor;
                this.size = size;
                draw ();
        }

        private static function brighten (color:uint, modifier:int):uint {
                var red:int   = (color >> 16) & 0xFF;
                var green:int = (color >> 8) & 0xFF;
                var blue:int = color & 0xFF;

                red += modifier;
                if (red>0xFF) {
                        red=0xFF;
                } else if (red < 0) {
                        red=0;

                }
                green+=modifier;
                if (green>0xFF) {
                        green=0xFF;
                } else if (green < 0) {
                        green=0;

                }
                blue+=modifier;
                if (blue>0xFF) {
                        blue=0xFF;
                } else if (blue < 0) {
                        blue=0;

                }
                return (red << 16) | (green << 8) | blue;
        }

        private function draw ():void {
                var
colors:Array=[brighten(bgColor,120),bgColor,brighten(bgColor,40)];
                var alphas:Array=[1,1,1];
                var ratios:Array=[0,127,255];
                var matrix:Matrix = new Matrix();
                matrix.createGradientBox (size * 4, size, Math.PI / 2, 0,
0);

                graphics.beginGradientFill (GradientType.LINEAR, colors,
alphas, ratios, matrix);
                graphics.drawRoundRect (0, 0, size * 4, size, 4);

                graphics.beginFill (0x000000, 0.1);
                graphics.drawRoundRect (0, size / 2, size * 4, size / 2, 4);
                graphics.endFill ();

                var colors2:Array=[0x0000ff,0x0000ff,0x0000ff,0x0000ff];
                var alphas2:Array=[.9, .6, .5, .1];
                var ratios2:Array=[0,127,128,255];
                var matrix2:Matrix = new Matrix();
                matrix2.createGradientBox (size, size/2, Math.PI / 2, 0, 0);

                graphics.beginGradientFill (GradientType.LINEAR, colors2,
alphas2, ratios2, matrix2);
                graphics.drawRect (0, size/2, size * 4, size/2);

                filters=[SHADOW,GLOW,BEVEL];
        }
}

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to