1 | /* */
|
---|
2 |
|
---|
3 | package {
|
---|
4 |
|
---|
5 | import flash.display.Sprite;
|
---|
6 | import flash.display.Stage;
|
---|
7 | import flash.text.TextField;
|
---|
8 | import flash.text.TextFieldType;
|
---|
9 | import flash.text.TextFormat;
|
---|
10 | import flash.events.Event;
|
---|
11 | import flash.text.TextFieldAutoSize;
|
---|
12 | //import string.Css;
|
---|
13 | import flash.text.StyleSheet;
|
---|
14 | import flash.events.TextEvent;
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 | public class ErrorMsg extends Sprite {
|
---|
19 |
|
---|
20 | public function ErrorMsg( msg:String ):void {
|
---|
21 |
|
---|
22 | var title:TextField = new TextField();
|
---|
23 | title.text = msg;
|
---|
24 |
|
---|
25 | var fmt:TextFormat = new TextFormat();
|
---|
26 | fmt.color = 0x000000;
|
---|
27 | fmt.font = "Courier";
|
---|
28 | fmt.size = 10;
|
---|
29 | fmt.align = "left";
|
---|
30 |
|
---|
31 | title.setTextFormat(fmt);
|
---|
32 | title.autoSize = "left";
|
---|
33 | title.border = true;
|
---|
34 | title.x = 5;
|
---|
35 | title.y = 5;
|
---|
36 |
|
---|
37 | this.addChild(title);
|
---|
38 | }
|
---|
39 |
|
---|
40 | public function add_html( html:String ): void {
|
---|
41 |
|
---|
42 | var txt:TextField = new TextField();
|
---|
43 |
|
---|
44 | var style:StyleSheet = new StyleSheet();
|
---|
45 |
|
---|
46 | var hover:Object = new Object();
|
---|
47 | hover.fontWeight = "bold";
|
---|
48 | hover.color = "#0000FF";
|
---|
49 |
|
---|
50 | var link:Object = new Object();
|
---|
51 | link.fontWeight = "bold";
|
---|
52 | link.textDecoration= "underline";
|
---|
53 | link.color = "#0000A0";
|
---|
54 |
|
---|
55 | var active:Object = new Object();
|
---|
56 | active.fontWeight = "bold";
|
---|
57 | active.color = "#0000A0";
|
---|
58 |
|
---|
59 | var visited:Object = new Object();
|
---|
60 | visited.fontWeight = "bold";
|
---|
61 | visited.color = "#CC0099";
|
---|
62 | visited.textDecoration= "underline";
|
---|
63 |
|
---|
64 | style.setStyle("a:link", link);
|
---|
65 | style.setStyle("a:hover", hover);
|
---|
66 | style.setStyle("a:active", active);
|
---|
67 | style.setStyle(".visited", visited); //note Flash doesn't support a:visited
|
---|
68 |
|
---|
69 | txt.styleSheet = style;
|
---|
70 | txt.htmlText = html;
|
---|
71 | txt.autoSize = "left";
|
---|
72 | txt.border = true;
|
---|
73 |
|
---|
74 | var t:TextField = this.getChildAt(0) as TextField;
|
---|
75 | txt.y = t.y + t.height + 10;
|
---|
76 | txt.x = 5;
|
---|
77 |
|
---|
78 | this.addChild( txt );
|
---|
79 |
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|