ErrorMsg.as 1.8 KB

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