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;
12 import flash
.utils
.Timer;
15 * Black, translucent, rounded button with text.
18 public class SexButton
extends Sprite
20 public var size
:Number;
21 public var bgColor
:uint = 0x000000;
22 public var fgColor
:uint = 0xffffff;
23 private var textControl
:TextField = new TextField();
24 private const padding
:Number = 6;
25 public const alphaNormal
:Number = 0.90;
26 public const alphaHover
:Number = 0.75;
28 public function SexButton
(_size
:Number,text
:String)
31 this.textControl
.text
= text
;
32 this.textControl
.textColor
= 0xffffff;
34 var tf
:TextFormat = new TextFormat();
37 tf
.align
= TextFormatAlign.CENTER
;
38 this.textControl
.setTextFormat
(tf
);
40 addChild
(textControl
);
41 this.textControl
.width
= _size
;
42 this.addEventListener
(MouseEvent.MOUSE_OVER
, this.onMouseOver
);
43 this.addEventListener
(MouseEvent.MOUSE_OUT
, this.onMouseOut
);
47 public function setText
(text
:String):void {
48 textControl
.text
= text
;
49 var tf
:TextFormat = new TextFormat();
52 tf
.align
= TextFormatAlign.CENTER
;
53 this.textControl
.setTextFormat
(tf
);
57 private function onMouseOver
(e
:MouseEvent):void {
58 this.alpha
= alphaHover
;
59 this.mouseChildren
= false;
61 private function onMouseOut
(e
:MouseEvent):void {
62 this.alpha
= alphaNormal
;
65 public function draw
():void {
66 graphics
.beginFill
(this.bgColor
);
67 textControl
.height
= textControl
.textHeight
+3;
68 textControl
.width
= textControl
.textWidth
;
69 if (textControl
.width
< size
)
71 textControl
.width
= size
;
73 var w
:Number = textControl
.width
+ (padding
* 2);
74 var h
:Number = textControl
.height
+ (padding
* 2);
75 graphics
.drawRoundRectComplex
(0, 0, w
, h
, 5, 5, 5, 5);
76 textControl
.x
= (w
/ 2) - (textControl
.width
/ 2);
77 textControl
.y
= (h
/ 2) - (textControl
.height
/ 2);
79 this.alpha
= alphaNormal
;