package {
    import flash.display.*;
    import flash.text.*;
    import flash.filters.*;

    //カスタムボタン
    public class CustomButton extends SimpleButton {

        //コンストラクタ    
        public function CustomButton() {

            var w:uint=30,h:uint=30,ew:uint=10,lw:uint=4;

            var downFilter:Array = new Array;
            downFilter.push(new BevelFilter(-3,45,0xddddff,0.5,0x000000,0.8));
            downFilter.push(new GlowFilter(0xFFFFFF, 0.7, 6, 6, 2, BitmapFilterQuality.HIGH, true, false));

            downState = makeRoundRect(w, h, ew, lw, 0x006600, 0x000000);
            downState.filters = downFilter;

            var overFilter:Array = new Array;
            overFilter.push(new BevelFilter(3,45,0xddddff,0.5,0x000000,0.8));
            overFilter.push(new GlowFilter(0xFFFFFF, 0.7, 6, 6, 2, BitmapFilterQuality.HIGH, true, false));

            overState = makeRoundRect(w, h, ew, lw, 0x00ff00, 0x000000);//オーバー
            overState.filters = overFilter;

            var upFilter:Array = new Array;
            upFilter.push(new BevelFilter(3,45,0xddddff,0.5,0x000000,0.8));
            upState = makeRoundRect(w, h, ew, lw, 0x777777, 0x000000);  //アップ
            upState.filters = upFilter;

            hitTestState=overState;      //当たり判定
            useHandCursor=true;       //ハンドアイコン

        }

        //角丸矩形の生成
        private function makeRoundRect(w:uint,h:uint,ew:uint,lw:uint,color:uint, lcolor:uint):Shape {
            var rrect:Shape=new Shape();
            rrect.graphics.lineStyle(lw,lcolor);    //線幅・線色
            rrect.graphics.beginFill(color);         //塗り潰し色
            rrect.graphics.drawRoundRect(0,0,w,h,ew);//XY座標,幅,高さ,角丸幅
            rrect.graphics.endFill();                //塗り潰し終了
            return rrect;
        }

    }
}