ActionScript 3 TextManager ActionScript 3.0类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 TextManager ActionScript 3.0类相关的知识,希望对你有一定的参考价值。
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);
};
};
};
};
以上是关于ActionScript 3 TextManager ActionScript 3.0类的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 ActionScript 3 SliceBitmap类
ActionScript 3 ActionScript 3中的XML循环
ActionScript 3 clickTag使用ActionScript 3
ActionScript 3 ActionScript 3中的反射
ActionScript 3 在ActionScript 3中嵌入字体
ActionScript 3 TextManager ActionScript 3.0类