flash文本竖排效果实现as3代码
程序员文章站
2023-10-11 15:05:10
根据某些特殊需求:需要实现flash文本竖排效果,本文搜集整理了一些实用代码,感兴趣的你不妨参考下,希望本文的知识点可以帮助到你... 13-02-20...
复制代码
代码如下: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;
}