[转] AS3能做化学符号+上下标吗?

化学符号等特殊符号,用AS表示出来.
化学符号如“水,二氧化碳,
带上下标的特殊符号:如平方米和立方米等,
能用AS表示出来.谢谢.



/**
* 部分代码参考Adobe文档:
* http://help.adobe.com/zh_CN/AS3LCR/Flash_10.0/flash/text/engine/package-detail.html
* by kingnare.com
*/
package
{
import __AS3__.vec.Vector;
import flash.display.Sprite;
import flash.text.engine.ContentElement;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
import flash.text.engine.FontWeight;
import flash.text.engine.GroupElement;
import flash.text.engine.TextBaseline;
import flash.text.engine.TextBlock;
import flash.text.engine.TextElement;
import flash.text.engine.TextLine;
[SWF(width="800", height="600", backgroundColor="#FFFFFF", framerate="24")]
public class TextEngineTest_TextBaseline extends Sprite
{
public function TextEngineTest_TextBaseline()
{
//字体属性
var fd1:FontDescription = new FontDescription(“Arial”);
//格式设置
var ef1:ElementFormat = new ElementFormat(fd1, 16);
var fd2:FontDescription = new FontDescription(“Arial”);
var ef2:ElementFormat = new ElementFormat(fd2, 10);
//将基线上移8个像素
ef2.baselineShift = -8;
//创建已设置格式的文本的字符串
var te1:TextElement = new TextElement(“A”,ef1);
var te2:TextElement = new TextElement(“3″,ef2);
var groupVector:Vector. = new Vector.();
groupVector.push(te1, te2);
//组成ContentElement集合
var groupElement = new GroupElement(groupVector);
//创建文本块
var textBlock:TextBlock = new TextBlock();
textBlock.content = groupElement;
//显示文本
createTextLines(textBlock);
}
//显示文本
private function createTextLines(textBlock:TextBlock):void
{
var yPos = 20;
var line_length:Number = 450;
var textLine:TextLine = textBlock.createTextLine(null,line_length);
while (textLine)
{
addChild(textLine);
textLine.x = 15;
yPos += textLine.height + 8;
textLine.y=yPos;
textLine=textBlock.createTextLine(textLine,line_length);
}
}
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值