TextManager ActionScript 3.0类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TextManager ActionScript 3.0类相关的知识,希望对你有一定的参考价值。
Allows easy usage of Fonts and TextField/TextFormat creation.
package com.Zimsical.Typography { import flash.display.Sprite; import flash.text.*; public class TextManager extends Sprite { public function TextManager() { }; public static function CreateTextFormat(fontName:String, fontColor:Number, fontSize:uint, LetterSpacing:int):TextFormat { var _myTextFormat:TextFormat = new TextFormat; _myTextFormat.font = fontName; _myTextFormat.color = fontColor; _myTextFormat.letterSpacing = LetterSpacing; _myTextFormat.bold = false; _myTextFormat.size = fontSize; return _myTextFormat; }; 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 { ListFonts(); var _myTextField:TextField = new TextField(); var _myTextFormat:TextFormat = CreateTextFormat(fontName, txtColor, txtSize, LetterSpacing); _myTextFormat.kerning = Kerning; if (HTMLText == true) { _myTextField.htmlText = fontTxt; } else { _myTextField.text = fontTxt; }; _myTextField.antiAliasType = "advanced"; if (Multiline) { _myTextField.multiline = true; _myTextField.wordWrap = true; } else { _myTextField.multiline = false; _myTextField.wordWrap = false; }; if (Input) { _myTextField.type = TextFieldType.INPUT; _myTextField.border = true; } else { _myTextField.type = TextFieldType.DYNAMIC; _myTextField.selectable = false; }; _myTextField.embedFonts = true; _myTextField.setTextFormat(_myTextFormat); _myTextField.x = X; _myTextField.y = Y; _myTextField.autoSize = TextFieldAutoSize.LEFT; return _myTextField; }; private static function ListFonts():void { var fonts:Array = Font.enumerateFonts(); trace(fonts.length); var font:Font; for (var i:int; i<fonts.length;i++) { font = fonts[i]; trace("name : "+font.fontName); trace("style : "+font.fontStyle); trace("type : "+font.fontType); }; }; }; };
以上是关于TextManager ActionScript 3.0类的主要内容,如果未能解决你的问题,请参考以下文章
将 Actionscript 1 转换为 Actionscript 3
如何将 actionscript 2 代码转换为 actionscript 3?
ActionScript 2.0 和 ActionScript 3.0 有啥区别
ActionScript 3 使用ActionScript 3暂停框架