1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package fortress;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
/**
* A simple class which abstracts button
* creation.
*/
class StdButton extends SimpleButton
{
public function new( text : String )
{
super();
draw( text );
}
private function draw( text : String )
{
var t = new TextField();
t.text = text;
t.autoSize = TextFieldAutoSize.LEFT;
var downSprite:Sprite = new Sprite();
downSprite.graphics.lineStyle(2, 0x202020);
downSprite.graphics.beginFill(0x00FF00);
downSprite.graphics.drawRect(0, 0, t.width, t.height);
downSprite.addChild( t );
t = new TextField();
t.text = text;
t.autoSize = TextFieldAutoSize.LEFT;
var upSprite:Sprite = new Sprite();
upSprite.graphics.lineStyle(2, 0x202020);
upSprite.graphics.beginFill(0xFFFF00);
upSprite.graphics.drawRect(0, 0, t.width, t.height);
upSprite.addChild( t );
upState = upSprite;
overState = upSprite;
downState = downSprite;
useHandCursor = true;
hitTestState = upSprite;
}
}
|