-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaEText.as
100 lines (82 loc) · 1.92 KB
/
SaEText.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package
{
import flash.events.*;
import flash.text.*;
import flash.display.Sprite;
public class SaEText extends Sprite
{
var txt:TextField = new TextField();
var _txtlayer:Sprite = new Sprite();
//var Tformat:TextFormat = new TextFormat();
public var evtC:Event = new Event("NEXT",true);
public function SaEText(color:String,Tformat:TextFormat)
{
// var fontArray:Array = Font.enumerateFonts(false);
// Tformat.font = fontArray[0].fontName;
//Tformat.size =parseInt(Tsize);// 36;
txt.textColor =uint("0x"+color);//ffcc66;
txt.autoSize =TextFieldAutoSize.LEFT;
if( Font.enumerateFonts(false).length>0)
{
txt.embedFonts=true;
}
txt.selectable =false;
txt.defaultTextFormat = Tformat;
txt.wordWrap=true;
txt.multiline=true;
txt.setTextFormat (Tformat);
addChild(_txtlayer);
_txtlayer.addChild(txt);
}
public function init()
{
txt.x = 0;
txt.y = 0;
_txtlayer.x = 960;
_txtlayer.y = 640;
txt.htmlText = "";
txt.visible = false;
}
//返回文字用于回放记录
public function showText(scenario:String):String
{
var ArrT = scenario.split("|");//ENGVER
var replaytxt="";
_txtlayer.x = 0;// parseInt(ArrT[1]);
_txtlayer.y = 0;// parseInt( ArrT[2]);
txt.x = parseInt(ArrT[1]);
txt.y = parseInt( ArrT[2]);
txt.width = ArrT[3];
if (ArrT[0] == "add")
{
txt.visible = true;
txt.htmlText += ArrT[4];
replaytxt=ArrT[4];
}
else if (ArrT[0] == "new")
{
txt.visible = true;
txt.htmlText = ArrT[4];
replaytxt=ArrT[4];
}
else if (ArrT[0] == "clear")
{
txt.x = 0;
txt.y = 0;
_txtlayer.x = 960;
_txtlayer.y = 640;
txt.htmlText = " ";
txt.visible = false;
_txtlayer.dispatchEvent(evtC);
}
if (ArrT.length >5)
{
if(ArrT[5]=="auto")
{
_txtlayer.dispatchEvent(evtC);
}
}
return replaytxt;
}
}
}