Button Event forked:27favorite:1lines:66license : MIT License modified : 2010-09-07 22:29:29 Embed Tweet package { import flash.display.Sprite; public class ButtonContainer extends Sprite { public function ButtonContainer() { var button:Button = new Button; button.setText('Click me!'); button.x = 9; button.y = 7; addChild(button); stage.scaleMode = "noScale"; stage.align = "tl"; } } } import flash.display.*; import flash.events.MouseEvent; import flash.text.TextFormat; import flash.text.TextField; import flash.events.Event; class Button extends Sprite { protected var _label:TextField; protected var _tfmOver:TextFormat = new TextFormat('_serif', 14, 0); protected var _tfmOut:TextFormat = new TextFormat('_serif', 14, 0xffffff); protected var _overSkin:Shape; public function Button() { _label = new TextField; _label.defaultTextFormat = _tfmOut; _label.x = _label.y = 1; _overSkin = new Shape; addEventListener(Event.ADDED_TO_STAGE, function _init(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, _init); init(); }); } protected function init():void { buttonMode = true; tabEnabled = false; _label.mouseEnabled = false; addChild(_overSkin); addChild(_label); addEventListener(MouseEvent.MOUSE_OVER, mouseOver); addEventListener(MouseEvent.MOUSE_OUT, mouseOut); mouseOut(null); } protected function mouseOver(e:MouseEvent):void { _overSkin.visible = true; _label.setTextFormat(_tfmOver); } protected function mouseOut(e:MouseEvent):void { _overSkin.visible = false; _label.setTextFormat(_tfmOut); } public function setText(value:String):void { _label.text = value; _label.width = _label.textWidth + 4; _label.height = _label.textHeight + 4; draw(graphics, 0x888888, 0x999999); draw(_overSkin.graphics, 0xbbbbbb, 0xcccccc); } private function draw(g:Graphics, lineColor:uint, fillColor:uint):void { g.clear(); g.lineStyle(2, lineColor); g.beginFill(fillColor); g.drawRect(0, 0, _label.width + 2, _label.height + 2); g.endFill(); } } Code Fullscreen Preview Fullscreen kuroarizuka event jam jam_session3 visible setTextFormat addEventListener tabEnabled height draw value width Event.ADDED_TO_STAGE mouseEnabled buttonMode textWidth textHeight removeEventListener Shape align addChild scaleMode graphics clear sort new page view favorite forked pv272 forked from: Button mapache forked:0 favorite:0lines:66 (diff:1) pv266 forked from: Button hirayama1985 forked:0 favorite:0lines:66 (diff:2) pv5556 トランプタワー破壊 ボタン - forked from: B.. AtuyL forked:2 favorite:22lines:491 (diff:654) tag: Alternativa3D Box2D alternativa pv1605 プチプチボタン chabudai forked:0 favorite:11lines:235 (diff:260) tag: ひまつぶし ストレス解消 pv31274 Click me, if you can keim_at_Si forked:22 favorite:89lines:500 (diff:531) tag: Beautifl逝き BetweenAS3 Frocessing SiON SiON_showcase beautiffl click cool game games 游戏 游戏源码 pv268 forked from: Button ArcWaterCash forked:0 favorite:0lines:66 (diff:1) pv3884 ストレス解消銃(Hand GUN) mousepancyo forked:4 favorite:13lines:245 (diff:303) pv1574 AdobeButton OKASUKE forked:1 favorite:11lines:357 (diff:490) tag: papervision3d stardust 1 2 3 4NEXT