How to use superscripting in flex?

前端 未结 2 828
清酒与你
清酒与你 2020-12-20 05:40

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 whic

相关标签:
2条回答
  • 2020-12-20 06:18

    This is the code I used in my iPad app to accomplish the above:

    var xmlText:String = "m/s <span baselineShift='superscript'>2</span>";
    var txtFlow:TextFlow = TextFlowUtil.importFromString(xmlText);
    var richTxt:RichText = new RichText();              
    richTxt.textFlow = txtFlow;
    this.addElement(richTxt);
    

    It is based on kaychaks and information I found from Adobe's website. The differences are

    • I took out the TextFlow markup but left in the HTML;
    • importFromString rather than importFromXML; and
    • I added this.addElement(richText) to display the element.
    0 讨论(0)
  • 2020-12-20 06:39

    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.

    0 讨论(0)
提交回复
热议问题