-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyTextField.as
51 lines (36 loc) · 974 Bytes
/
MyTextField.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
39
40
41
42
43
44
45
46
47
48
49
50
package
{
import flash.display.*;
import flash.text.*;
public class MyTextField extends TextField
{
[Embed(source="fonts/albach.ttf", fontName='mydefault', mimeType='application/x-font')]
public static var FontSrc : Class;
public function MyTextField (_x: Number, _y: Number, _text: String, _align: String = TextFieldAutoSize.CENTER, textSize: Number = 16, _fontName: String = null)
{
x = _x;
y = _y;
textColor = 0xFFFFFF;
selectable = false;
mouseEnabled = false;
if (! _fontName)
{
_fontName = "mydefault";
}
var _textFormat : TextFormat = new TextFormat(_fontName, textSize);
_textFormat.align = _align;
defaultTextFormat = _textFormat;
embedFonts = true;
autoSize = _align;
text = _text;
if (_align == TextFieldAutoSize.CENTER)
{
x = _x - textWidth / 2;
}
else if (_align == TextFieldAutoSize.RIGHT)
{
x = _x - textWidth;
}
}
}
}