Skip to content

Instantly share code, notes, and snippets.

@grvgl
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grvgl/f32a49071015ae3aab66 to your computer and use it in GitHub Desktop.
Save grvgl/f32a49071015ae3aab66 to your computer and use it in GitHub Desktop.
<b> <i> Superscript Subscript in Actionscript
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.Font;
public class BoldItalicSubSuperscript extends MovieClip {
// Free Subscript and Superscript fonts are available at
// https://storage.googleapis.com/ggshow/files/fonts/GGSUBSCR.TTF
// https://storage.googleapis.com/ggshow/files/fonts/GGSUPERS.TTF
// And the whole tutorial @ http://www.ggshow.com/how-to-use-subscript-superscript-in-dynamic-and-input-text-field/
public function BoldItalicSubSuperscript() {
var txtFld: TextField = new TextField();
txtFld.width = 600;
txtFld.height = 600;
txtFld.multiline = true;
txtFld.embedFonts = true;
txtFld.htmlText = "<font face='Arial' size='24'>I have just been <font face='Arial Bold' size='24'>bolded.</font></font>\n<font face='Arial' size='24'>And a line break for </font><font face='Arial Italic' size='24'>italic text.</font>";
txtFld.htmlText += "<font face='Arial' size='24'>This is subscript</font><font face='GG Subscript' size='24'>0123456789qwertyuioplkjhgfdsazxcvbnm</font>";
txtFld.htmlText += "<font face='Arial' size='24'>This is superscript</font><font face='GG Superscript' size='24'>0123456789qwertyuioplkjhgfdsazxcvbnm</font>";
this.addChild(txtFld);
stop();
traceFontDetails();
}
// Trace the names of fonts used in the fla and use the same name to create new font in the library.
// Use the same name to format text.
public function traceFontDetails() {
var fonts: Array = Font.enumerateFonts();
for (var i: int = 0; i < fonts.length; i++)
trace(fonts[i].fontName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment