1 package org
.sevenchan
.dongs
.ui
3 import flash
.display
.SimpleButton;
4 import flash
.display
.Shape;
5 import flash
.display
.Sprite;
6 import flash
.events
.Event;
7 import flash
.events
.MouseEvent;
8 import flash
.text
.TextField;
9 import flash
.text
.TextFormat;
10 import flash
.text
.TextFieldAutoSize;
11 import flash
.text
.TextFormatAlign;
17 public class TinyButton
extends Sprite implements IHovertextRecipient
19 public var bgColor
:uint = 0x000000;
20 public var fgColor
:uint = 0xffffff;
21 private var textControl
:TextField = new TextField();
22 private const padding
:Number = 6;
23 public var alphaNormal
:Number = 0.90;
24 public var alphaHover
:Number = 0.75;
26 public function TinyButton
(text
:String)
28 this.textControl
.text
= text
;
29 this.textControl
.textColor
= 0xffffff;
31 var tf
:TextFormat = new TextFormat();
34 tf
.align
= TextFormatAlign.CENTER
;
35 this.textControl
.setTextFormat
(tf
);
37 addChild
(textControl
);
38 this.addEventListener
(MouseEvent.MOUSE_OVER
, this.onMouseOver
);
39 this.addEventListener
(MouseEvent.MOUSE_OUT
, this.onMouseOut
);
40 this.alpha
= alphaNormal
;
44 public function setText
(text
:String):void {
45 textControl
.text
= text
;
48 private function onMouseOver
(e
:MouseEvent):void {
49 this.alpha
= alphaHover
;
50 this.mouseChildren
= false;
52 private function onMouseOut
(e
:MouseEvent):void {
53 this.alpha
= alphaNormal
;
56 public function draw
():void {
58 graphics
.beginFill
(this.bgColor
);
59 textControl
.height
= textControl
.textHeight
+4;
60 textControl
.width
= textControl
.textWidth
+3.5;
63 textControl
.x
= (w
/ 2) - (textControl
.width
/ 2);
64 textControl
.y
= (h
/ 2) - (textControl
.height
/ 2);
65 graphics
.drawCircle
(w
/2, h
/2, w
/2);
69 /* INTERFACE IHovertextRecipient */
71 public function setHoverText
(text
:String):void
76 public function getHoverText
():String