[转] 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);}}}}