text的竖排和横排

 

                        var _textFiled:TextField = new TextField();
_textFiled.text = "横排or竖排";
_textFiled.wordWrap = true;
_textFiled.selectable = false;
_textFiled.antiAliasType = AntiAliasType.ADVANCED;
addChild(_textFiled);

关于text的竖排有两种方法:

①:

_textFiled.text = _textFiled.text.split("").join("\n");

②:

                       var fontDescription:FontDescription=new FontDescription("宋体");
var format:ElementFormat = new ElementFormat();
format.fontSize = 32;
format.color = 0xfffff;
format.textRotation = TextRotation.AUTO;
format.fontDescription=fontDescription;
var textElement:TextElement=new TextElement("",format);
var textBlock:TextBlock = new TextBlock();
textBlock.content=textElement;
textBlock.lineRotation=TextRotation.ROTATE_90;
var linePosition:Number=0;
var previousLine:TextLine=null;
while (true) {
var textLine:TextLine = textBlock.createTextLine(
previousLine,
180);
if (textLine==null) {
break;
}
textLine.y=20;
textLine.x=linePosition;
linePosition-=25;
addChild(textLine);
previousLine=textLine;
};

 

然后就是恢复横排了:

1 _textFiled.text = _textFiled.text.split("\r").join("");











posted @ 2011-11-08 09:23  Hanami  阅读(1222)  评论(0编辑  收藏  举报