flash文本竖排效果实现as3代码

平面设计 2021-07-03 14:34www.168986.cn平面设计培训

复制代码
代码如下:

import flash.text.engine.TextBlock;
import flash.text.engine.ElementFormat;
import flash.text.engine.ContentElement;
import flash.text.engine.TextElement;
var linePosition:Number = this.stage.stageWidth - 45;
var tb:TextBlock=new TextBlock();
var shijingText:String="葛之覃兮,施于中谷,维叶萋萋。黄鸟于飞,集于灌木,其鸣喈喈。葛之覃兮,施于中谷,维叶莫莫。是刈是濩,为絺为绤,服之无斁。言告师氏,言告言归。薄污我私,薄浣我衣。害浣害否,归宁父母。";
var format:ElementFormat = new ElementFormat();
format.fontSize = 12;
format.color = 0xCC0000;
format.textRotation = TextRotation.AUTO;
tb.lineRotation=TextRotation.ROTATE_90;
tb.baselineZero = TextBaseline.IDEOGRAPHIC_CENTER;
tb.content=new TextElement(shijingText,format);
var previousLine:TextLine = null;
while (true)
{
var textLine:TextLine = tb.createTextLine(previousLine, 180);
if (textLine == null)
break;
textLine.y = 20;
textLine.x = linePosition;
linePosition -= 25;
addChild(textLine);
previousLine = textLine;
}

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by