Posted By

Praimen on 05/22/11


Tagged

flash embed text as3


Versions (?)

Text Embed in Flash Builder


 / Published in: ActionScript 3
 

URL: http://www.flashdevelop.org/community/viewtopic.php?f=13&t=7999

embeded multiple fonts

  1. package
  2. {
  3.  
  4. import flash.text.Font;
  5.  
  6. public class MyFonts
  7. {
  8.  
  9. [Embed(source = '../fonts/visitor2.ttf', fontName = 'visitor2', embedAsCFF = 'false')]
  10. private var visitor2:Class;
  11.  
  12. [Embed(source = '../fonts/bitlow.ttf', fontName = 'bitlow', embedAsCFF = 'false')]
  13. private var bitlow:Class;
  14.  
  15. [Embed(source = '../fonts/Sansation_Regular.ttf', fontName = 'Sansation_Regular', embedAsCFF = 'false')]
  16. private var Sansation_Regular:Class;
  17.  
  18. [Embed(source = '../fonts/LiberationSerif_Regular.ttf', fontName = 'LiberationSerif_Regular', embedAsCFF = 'false')]
  19. private var LiberationSerif_Regular:Class;
  20.  
  21. [Embed(source = '../fonts/f04b_08.ttf', fontName = 'f04b_08', embedAsCFF = 'false')]
  22. private var f04b_08:Class;
  23.  
  24. [Embed(source = '../fonts/calibri.ttf', fontName = 'calibri', embedAsCFF = 'false')]
  25. private var calibri:Class;
  26.  
  27. [Embed(source = '../fonts/baars.ttf', fontName = 'baars', embedAsCFF = 'false')]
  28. private var baars:Class;
  29.  
  30. [Embed(source = '../fonts/BabelSans.ttf', fontName = 'BabelSans', embedAsCFF = 'false')]
  31. private var BabelSans:Class;
  32.  
  33.  
  34.  
  35. private static const MyFonts:Array =
  36. [
  37. 'visitor2',
  38. 'bitlow',
  39. 'Sansation_Regular',
  40. 'LiberationSerif_Regular',
  41. 'f04b_08',
  42. 'calibri',
  43. 'baars',
  44. 'BabelSans'
  45. ];
  46.  
  47. public function MyFonts()
  48. {
  49. var length:int = MyFonts.length;
  50.  
  51. for (var i:int; i < length; i++)
  52. {
  53. Font.registerFont(this[MyFonts[i]]);
  54. }
  55. }
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
  62.  
  63. private var tfStatus:TextField;
  64.  
  65. private function showStatusMessage(message:String):void
  66. {
  67. if (!tfStatus)
  68. {
  69. tfStatus = new TextField();
  70. var format:TextFormat = new TextFormat();
  71. format.size = 10;
  72. format.align = TextFormatAlign.CENTER;
  73. format.font = "Sansation_Regular";
  74. tfStatus.embedFonts = true;
  75. //tfStatus.autoSize = TextFieldAutoSize.CENTER;
  76. tfStatus.defaultTextFormat = format;
  77. tfStatus.text = message;
  78. tfStatus.width = stage.stageWidth - 10;
  79. tfStatus.wordWrap = false;
  80. tfStatus.x = 5;
  81. tfStatus.y = 460;
  82. tfStatus.antiAliasType = AntiAliasType.ADVANCED;
  83. tfStatus.visible = true;
  84. addChild(tfStatus);
  85. }
  86. else
  87. {
  88. tfStatus.visible = true;
  89. tfStatus.text = message;
  90. }
  91. }

Report this snippet  

You need to login to post a comment.