Login / Sign Up

Your cart has 3 products totalling 214.00 USD

Using text fields in ActionScript 2 and font embedding

 

 

This is how I like to create text fields with AS2, avoiding using the Stage to add dynamic text fields:

var txt:TextField = createTextField("txt", 0, 0, 0, 0, 0);
txt.autoSize = true;
txt.multiline = true;
txt.selectable = false;
txt.wordWrap = false;
txt.embedFonts = true;
txt.html = true;
txt.htmlText = "This is my text";        

txtFormat = new TextFormat();
txtFormat.font = "my_font";
txtFormat.size = 13;
txt.setTextFormat(txtFormat);


One more thing is needed to be done, define my_font in the Library, by selecting New Font in the context menu after clicking the icon in the upper right corner of the Library. You must select "Export for ActionScript" and "Export in first frame", and the Identifier should be named my_font.

Bare in mind that the actual font is not saved in the FLA file, it is actually a reference to the font on your hard-drive. When you're sharing the FLA with someone you must remember to put the font file next to it, and the person using your FLA file should install first the font in his/her OS.

A comprehensive approach on this nightmare issue these fonts in Flash prove to be can be found here: http://www.connectedpixel.com/blog/fonts/embedding

 

  • COMMENTS
  • SEARCH COMMENTS
DiseƱo web Ciudad Real

Nice tip. I always have issues with embedding fonts in flash.

Posted 9 Months Ago
awesome

you must set autosize after specifying text..

Posted 1 Year Ago

Leave a Reply

Only alphanumeric characters allowed
Please type a message!
Format your comments using Textile: *bold*, _italic_, "link text":address, @code@