Skip to content

Embed fonts in AS3 with TextInput component

Michael Hulse edited this page Nov 9, 2015 · 3 revisions

Because this was such a headache, I’m documenting it here:

From the Libray panel flyout menu, choose “New Font...”:

screenshot 2015-11-09 15 32 05

Self-explanatory settings:

screenshot 2015-11-09 15 33 52

screenshot 2015-11-09 15 33 54

Here’s the code:

var format:TextFormat = new TextFormat();
var klass:Class = getDefinitionByName('DynaFont') as Class;
var chars:Font = new klass(); // Or, just `new DynaFont()`.

format.color = 0x000000;
format.size = 28;
format.font = chars.fontName;
format.align = 'left';
format.bold = false;

this.setStyle('embedFonts', true);
this.setStyle('textFormat', format); // Apply style changes.
Clone this wiki locally