SimpleButton flashrod forked:0favorite:5lines:69license : MIT License modified : 2010-02-19 23:11:42 Embed Tweet package { import flash.display.DisplayObject; import flash.display.GradientType; import flash.display.Shape; import flash.display.SimpleButton; import flash.display.Sprite; import flash.filters.BlurFilter; import flash.filters.DropShadowFilter; import flash.filters.GlowFilter; import flash.geom.Matrix; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; public class Hello extends Sprite { public function Hello() { var us:DisplayObject = createState(100, 40, 24, 24, 4, 0x0000FF, "OK"); var os:DisplayObject = createState(100, 40, 24, 24, 4, 0x4444FF, "OK"); var ds:DisplayObject = createState(100, 40, 24, 24, 0, 0x4444FF, "OK"); ds.x = 4; ds.y = 4; var b:SimpleButton = new SimpleButton(us, os, ds, us); b.x = 100; b.y = 100; addChild(b); } /** ボタンの表示イメージを作ります。 * @param w 幅 * @param h 高さ * @param rx 角丸幅 * @param ry 角丸高さ * @param d ドロップシャドウ距離 * @param c 色 * @param t ラベルテキスト */ public static function createState(w:int, h:int, rx:int, ry:int, d:int, c:uint, t:String):DisplayObject { var s:Sprite = new Sprite(); s.graphics.beginFill(c); s.graphics.drawRoundRect(0, 0, w, h, rx, ry); s.graphics.endFill(); s.filters = [ new GlowFilter(0x000000, 1, 4, 4, 2, 1, true), new DropShadowFilter(d, 45, 0, 0.5) ]; var s1:Shape = new Shape(); var m1:Matrix = new Matrix(); m1.createGradientBox(w-4, h/2-4, Math.PI/2); s1.graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF], [1, 0.25], [0, 255], m1); s1.graphics.drawRoundRect(0, 0, w-4, h/2-4, rx-2, rx-2); s1.graphics.endFill(); s1.x = 2; s1.y = 2; s.addChild(s1); var s2:Shape = new Shape(); var m2:Matrix = new Matrix(); m2.createGradientBox(w-4-4, h/2-4, Math.PI/2); s2.graphics.beginGradientFill(GradientType.LINEAR, [0xFFFFFF, 0xFFFFFF], [0.05, 0.75], [0, 255], m2); s2.graphics.drawRoundRect(0, 0, w-4-4, h/2-4, rx-2, rx-2); s2.graphics.endFill(); s2.filters = [ new BlurFilter(8, 8) ]; s2.x = 2+2; s2.y = h/2+2; s.addChild(s2); var l:TextField = new TextField(); l.autoSize = TextFieldAutoSize.LEFT; var tf:TextFormat = new TextFormat(); tf.font = "Verdana"; tf.bold = true; tf.color = 0xFFFFFF; tf.size = h/2; l.defaultTextFormat = tf; l.text = t; l.filters = [ new DropShadowFilter(4, 45, 0, 0.3) ]; l.alpha = 0.9; l.x = (w-l.width)/2; l.y = (h-l.height)/2; s.addChild(l); return s; } } } Code Fullscreen Preview Fullscreen tjoen itou_hiroki siouxcitizen.. marathon332 : ButtonsGood Square Drawing keim_at_Si : aquasimple aqua by code Buttons aqua Matrix bold filters addChild GlowFilter TextFormat alpha height width createGradientBox font size Math.PI color text String uint Sprite int