-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextManager.as
53 lines (45 loc) · 1.41 KB
/
TextManager.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
51
52
53
package{
import flash.text.TextField;
import flash.text.StyleSheet;
import flash.text.AntiAliasType;
import flash.text.TextFieldType;
import flash.text.TextFormat;
public class TextManager{
private static var styleSheet:StyleSheet = new StyleSheet();
function TextManager(){
throw new Error("You shouldn't use the new operator!");
}
public static function registerCSS(data:*):void{
styleSheet.parseCSS(String(data))
}
public static function createText(style:String):TextField{
var tf:TextField = new TextField();
tf.defaultTextFormat = styleSheet.transform(styleSheet.getStyle(style));
tf.embedFonts = true;
tf.multiline = true;
tf.antiAliasType = AntiAliasType.ADVANCED;
tf.selectable = false;
tf.mouseEnabled = false;
return tf;
}
public static function createInputText(style:String, length:int = 40):TextField{
var tf:TextField = new TextField();
tf.defaultTextFormat = styleSheet.transform(styleSheet.getStyle(style));
tf.embedFonts = true;
tf.type = TextFieldType.INPUT;
tf.antiAliasType = AntiAliasType.ADVANCED;
tf.maxChars = length;
return tf;
}
public static function createHTMLText():TextField{
var tf:TextField = new TextField();
tf.styleSheet = styleSheet;
tf.embedFonts = true;
tf.multiline = true;
tf.antiAliasType = AntiAliasType.ADVANCED;
tf.selectable = false;
tf.mouseEnabled = false;
return tf;
}
}
}