TextManager ActionScript 3.0类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TextManager ActionScript 3.0类相关的知识,希望对你有一定的参考价值。

Allows easy usage of Fonts and TextField/TextFormat creation.
  1. package com.Zimsical.Typography {
  2.  
  3. import flash.display.Sprite;
  4. import flash.text.*;
  5.  
  6. public class TextManager extends Sprite {
  7.  
  8. public function TextManager() {
  9.  
  10. };
  11.  
  12. public static function CreateTextFormat(fontName:String, fontColor:Number, fontSize:uint, LetterSpacing:int):TextFormat {
  13. var _myTextFormat:TextFormat = new TextFormat;
  14. _myTextFormat.font = fontName;
  15. _myTextFormat.color = fontColor;
  16. _myTextFormat.letterSpacing = LetterSpacing;
  17. _myTextFormat.bold = false;
  18. _myTextFormat.size = fontSize;
  19. return _myTextFormat;
  20. };
  21.  
  22. public static function CreateTextField(LetterSpacing:int, Kerning:Boolean, X:int, Y:int, Input:Boolean, Multiline:Boolean, htmlText:Boolean, txtSize:int, fontTxt:String, txtColor:Number, fontName:String):TextField {
  23. ListFonts();
  24. var _myTextField:TextField = new TextField();
  25. var _myTextFormat:TextFormat = CreateTextFormat(fontName, txtColor, txtSize, LetterSpacing);
  26. _myTextFormat.kerning = Kerning;
  27. if (HTMLText == true) {
  28. _myTextField.htmlText = fontTxt;
  29. } else {
  30. _myTextField.text = fontTxt;
  31. };
  32. _myTextField.antiAliasType = "advanced";
  33. if (Multiline) {
  34. _myTextField.multiline = true;
  35. _myTextField.wordWrap = true;
  36. } else {
  37. _myTextField.multiline = false;
  38. _myTextField.wordWrap = false;
  39. };
  40. if (Input) {
  41. _myTextField.type = TextFieldType.INPUT;
  42. _myTextField.border = true;
  43. } else {
  44. _myTextField.type = TextFieldType.DYNAMIC;
  45. _myTextField.selectable = false;
  46. };
  47. _myTextField.embedFonts = true;
  48. _myTextField.setTextFormat(_myTextFormat);
  49. _myTextField.x = X;
  50. _myTextField.y = Y;
  51. _myTextField.autoSize = TextFieldAutoSize.LEFT;
  52. return _myTextField;
  53. };
  54.  
  55. private static function ListFonts():void {
  56.  
  57. var fonts:Array = Font.enumerateFonts();
  58. trace(fonts.length);
  59. var font:Font;
  60. for (var i:int; i<fonts.length;i++) {
  61. font = fonts[i];
  62. trace("name : "+font.fontName);
  63. trace("style : "+font.fontStyle);
  64. trace("type : "+font.fontType);
  65. };
  66.  
  67. };
  68.  
  69. };
  70.  
  71. };

以上是关于TextManager ActionScript 3.0类的主要内容,如果未能解决你的问题,请参考以下文章

将 Actionscript 1 转换为 Actionscript 3

如何将 actionscript 2 代码转换为 actionscript 3?

ActionScript 2.0 和 ActionScript 3.0 有啥区别

ActionScript 3 使用ActionScript 3暂停框架

ActionScript 3 在Actionscript中绘制缩放对象

ActionScript 3 在ActionScript中打开相机