How to use subscript & superscript in dynamic and input text field
Issue:
- Unable to use subscript or superscript in dynamic and input text field.
- Unable to display subscript or superscript for external loaded text.
- Unable to use <sub> & <sup> tags in dynamic or input text field.
Reason:
<sub> & <sup> tags are not supported by Flash.
TechNote: Subscript and superscript fail in dynamic and input text fields
LiveDocs: Supported HTML tags
Solution:
- Download & install GG Subscript & GG Superscript TrueType fonts. You will need to restart Flash software after installed fonts.
- Create a dynamic text field with Arial font embeded. Set the HTML property to true.
- Create a dynamic text field with GG Subscript font embeded.
- Create a dynamic text field with GG Superscript font embeded.
Use HTML tag to set text to subscript or superscript like below:
Adobe<font face="GG Superscript">TM</font>
If you are using ActionScript to test the htmlText, use script like below:
my_txt.text = "Adobe<font face=\"GG Superscript\">TM</font>";
View sample: superscript.swf
Download sample: superscript.fla superscript.swf
Updated
(2008-09-21)
A new set of superscript & subscript fonts includes both sans & serif type, with more complete & improved glyphs, standard scale & shift, is now available to be downloaded (free) from here.
Updated
(2010-10-23)
Another set of fonts for displaying square root (SQRT), cube root, nth root, and other roots formula in dynamic and input text field is now available here.


29 comments
- aaron
flo
http://www.psyked.co.uk/adobe/flash/superscript-and-subscript-with-actionscript.htm
http://jasonbejot.com/?p=3
I've tested this solution in Flash Player 7, 8, 9 (CS3), both AS2 & AS3, it works.
If you have problem using the fonts in Flash 7, you can send me your FLA file I'll look at it.
If you need multiple style (regular, bold, italic, bold italic), you will need to use multiple dynamic text field to embed the fonts. E.g. create 4 dynamic text fields, one with regular font, one to embed bold font, one for italic, and one for bold italic. Embed font for all the 4 text fields.
If you need only regular and bold styles, use only 2 dynamic text fields for font embeding. Now you should be able to have bold in your superscript.
Adobe<font face="GG Superscript"><b>TM <b>Adobe<font face="GG Superscript">TM</font></b>
If I import it with Faux Bold checked it doesn't seem to change anything.
Nils Ellis
Integrated Marketing Communications – Sr. Designer
Advanced Micro Devices, Inc.
This seems to work offline but not online. Or is there something I missed?
since I created the textfield dynamically from script, I need to create a font object and assign it to the textformat instance. then set the textfield's embedFont property to true.
Leave a comment