如何在flex中使用上标? [英] How to use superscripting in flex?

查看:26
本文介绍了如何在flex中使用上标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 flex 中添加一个标签以显示 m/s2(每秒读取米数).我需要为此使用上标.

I want to add a label in flex to display m/s2 (read meters per second square). I would need to use superscripting for this.

我已经尝试了以下代码,这给了我一个编译错误.

I have tried out the following code which is giving me a compilation error.

var richtxt1:RichText = new RichText();
richtxt1.text="m/s";
var richtxt2:RichText = new RichText();
var span:SpanElement = new SpanElement();
span.text = "2";    
span.baselineShift = "superscript"; 
richtxt2.addChild(span);
richtxt1.text=rixhtxt1.txt + richtxt2.text

我收到 richtxt2.addChild(span)

错误是

Implicit coercion of a value of type flashX.textLayout.elements.SpanElement 
to unrelated type flash.Display.DisplayObject

推荐答案

我认为你必须做这样的事情

I think you've to do something like this

var xmlText:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
                     "m/s <span baselineShift='superscript'>2</span>" +
                     "</TextFlow>";

var txtFlow:TextFlow = TextFlowUtil.importFromXML(xmlText);

var richTxt:RichText = new RichText();
richtxt.textFlow = txtFlow;

我没有测试过,所以请原谅任何编译错误.

I've not tested it so please excuse me of any compilation errors.

这篇关于如何在flex中使用上标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆