-
Notifications
You must be signed in to change notification settings - Fork 1
/
Button.as
39 lines (27 loc) · 1018 Bytes
/
Button.as
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
package
{
import flash.display.*;
import flash.text.*;
import flash.events.MouseEvent;
public class Button extends Sprite
{
public var textField: MyTextField;
public function Button (_text: String, _textSize: Number = 16, _width: Number = 0, _colour: int = 0x000000)
{
textField = new MyTextField(10, 5, _text, "left", _textSize);
var _height: Number = textField.height + 10;
_width = Math.max(_width, textField.width + 20);
textField.x = _width / 2 - textField.width / 2;
addChild(textField);
/*graphics.beginFill(_colour);
graphics.drawRect(0, 0, _width, _height);
graphics.endFill();
graphics.lineStyle(4, 0xffffff);
graphics.drawRect(0, 0, _width, _height);*/
buttonMode = true;
mouseChildren = false;
addEventListener(MouseEvent.ROLL_OVER, function (param: * = 0) : void {textField.textColor = 0x00FF00});
addEventListener(MouseEvent.ROLL_OUT, function (param: * = 0) : void {textField.textColor = 0xFFFFFF});
}
}
}