-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaETrace.as
80 lines (66 loc) · 1.7 KB
/
SaETrace.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
package
{
import flash.text.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.Sprite;
public class SaETrace extends Sprite
{
var txt:TextField = new TextField();
var Tformat:TextFormat = new TextFormat();
var tracetimer:Timer = new Timer(5000,1);//显示提示信息的时间
public function SaETrace()
{
txt.x = 0;
txt.y = 0;
txt.text = "";
txt.visible = false;
txt.autoSize = TextFieldAutoSize.LEFT;
txt.selectable = false;
txt.width=900;
txt.wordWrap = true;
txt.multiline = true;
txt.background =true;
addChild(txt);
tracetimer.addEventListener(TimerEvent.TIMER_COMPLETE,ontraceTimerComplete);
}
//设定样式
public function init(colorB:String,colorT:String,dur:int,Tformat:TextFormat)
{
// var fontArray:Array = Font.enumerateFonts(false);
// Tformat.font = fontArray[0].fontName;
// Tformat.size = 22;
txt.defaultTextFormat = Tformat;
if( Font.enumerateFonts(false).length>0)
{
txt.embedFonts = true;
}
txt.textColor =uint("0x"+colorT);//#333366;
txt.backgroundColor=uint("0x"+colorB);
txt.alpha=0.5;
tracetimer = new Timer(dur,1);//显示提示信息的时间
tracetimer.addEventListener(TimerEvent.TIMER_COMPLETE,ontraceTimerComplete);
}
//显示,开始计时
public function showText(scenario:String)
{
txt.visible = true;
if (txt.text == "")
{
trace("--saetrace===");
txt.htmlText = scenario;
}else{
trace("--saetrace+++");
txt.htmlText +=(scenario);
}
tracetimer.reset();
tracetimer.start();
}
//计时结束
function ontraceTimerComplete(event:TimerEvent):void
{
txt.text="";
txt.visible=false;
}
}
}