19
Apr.2007

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:

  1. Download & install GG Subscript & GG Superscript TrueType fonts. You will need to restart Flash software after installed fonts.
  2. Create a dynamic text field with Arial font embeded. Set the HTML property to true.
  3. Create a dynamic text field with GG Subscript font embeded.
  4. Create a dynamic text field with GG Superscript font embeded.
  5. 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.


free b2evolution skin

29 comments

Comment from: Aisha [Visitor]
Thanks sooo much, I just had a very disappointing experience when I found that my way of importing various unicode characters from text files only worked on Macs, and I was at a loss - but you fixed the subscript/superscript part of my problem (the biggest part). Thanks again
07/13/07 @ 22:27
Comment from: senthil kumar [Visitor] Email
Just now im hearing this superscript along with the flash. Nice to learn
08/21/07 @ 17:32
Comment from: Yin [Visitor] Email
wow. you totally made my day. I've been trying to put subscripts in all week!! Thanks so much!
11/08/07 @ 06:27
Comment from: GW [Visitor]
Works great! You made my day. Thanks so much.
12/21/07 @ 01:09
Comment from: Aaron Beall [Visitor] Email
You don't know how long I've been looking for these two fonts. Well, I'll tell you: about the last 4 years. All other hacks I've tried have had issues. Thank-you very much for sharing!!

- aaron
01/24/08 @ 11:17
Comment from: flo [Visitor] Email
Couldn't believe there's no native support for subscript tags in flash. You helped me out... thank you so much!

flo
02/13/08 @ 19:01
Comment from: priti [Visitor] Email
thank u so much.
05/30/08 @ 19:42
Comment from: G [Member] Email
Here is a nice solution for using GG superscript & GG subscript with <sup> & <sub> tag

http://www.psyked.co.uk/adobe/flash/superscript-and-subscript-with-actionscript.htm
07/12/08 @ 18:28
Comment from: G [Member] Email
Also work in flex

http://jasonbejot.com/?p=3
07/12/08 @ 18:32
Comment from: Wally [Visitor] Email
thats good
09/28/08 @ 20:26
Comment from: Evan Gifford [Visitor] Email
Nice tip, it's a real timesave. Thank you very much!
10/23/08 @ 07:57
Comment from: JRM [Visitor] Email
Am I right in saying this doesn't work in Flash 7? (I know who targets flash 7...!)
01/14/09 @ 19:05
Comment from: G [Member] Email
Hi JRM,

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.
01/14/09 @ 23:09
Comment from: parkej60 [Visitor] Email
Anyone know if there is a way to get this text to be bold?
01/18/09 @ 23:36
Comment from: G [Member] Email
You need to ensure that you have embeded the bold font. Set the font to bold for the dynamic text field which used to embed font.

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>
01/19/09 @ 00:51
Comment from: parkej60 [Visitor] Email
The GG font apparently only allows for you to embed it as a regular font style, it doesn't appear to have a bold font style.

If I import it with Faux Bold checked it doesn't seem to change anything.

01/19/09 @ 03:09
Comment from: G [Member] Email
Example below uses GG Superscript Sans font, with regular, bold, italic, bold italic.

01/19/09 @ 12:25
Comment from: jairus [Visitor] Email
wow, thanks a lot for the great tip, works perfectly for me :D
02/02/09 @ 10:57
Comment from: delux [Visitor] Email
Great font's,serious problem solved on this project I'm working on, in fact before I found this site I was about to buy them of that guys site you talk about above (the fairly blatant theft is incredible) instead I'll make a donation to you, thanks.
07/16/09 @ 00:31
Comment from: nils ellis [Visitor] Email
I can't even tell you how much this fix has helped my team and I!!

Nils Ellis
Integrated Marketing Communications – Sr. Designer
Advanced Micro Devices, Inc.
08/06/09 @ 00:16
Comment from: Jitendra [Visitor]
It's really a great help of me. I have been searching the solution for last many days. Thank you so much. Jitendra Panwar
09/08/09 @ 09:56
Comment from: Stephen [Visitor] Email
How to make this work for embedded flash file inside html.

This seems to work offline but not online. Or is there something I missed?
01/21/10 @ 08:38
Comment from: Stephen [Visitor] Email
OK, I figured it out.

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.

01/21/10 @ 10:50
Comment from: Jori [Visitor] Email
You just saved my graduation project with this information! Finally able to write decent molecular formulas! Thanks a BILLION!!!
05/06/10 @ 07:48
Comment from: Friv [Visitor] Email
Thank you .
10/10/10 @ 20:20
Comment from: Yamini [Visitor] Email
Hey Thanks a lot..... I have been tried of reading all useless posts. This is great. Thank you :)
10/12/10 @ 06:14
Comment from: Yamini [Visitor] Email
Can somebody help me to create square root in flash As2 dynamic field??
10/12/10 @ 10:36
Comment from: G [Member] Email
Yes the square root is on its way ^^
10/22/10 @ 14:15
Comment from: Jocuri [Visitor]
You just saved my graduation project with this information! Finally able to write decent molecular formulas! Thanks a BILLION!!!
09/20/11 @ 21:29

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
 

Notice: Undefined property: stdClass::$platform in C:\inetpub\vhosts\ggshow.com\httpdocs\inc\sessions\model\_hit.class.php on line 469

Notice: Undefined property: stdClass::$platform in C:\inetpub\vhosts\ggshow.com\httpdocs\inc\sessions\model\_hit.class.php on line 471