Tag Archives: embedding

Using Embedded Library Fonts in AS2 and Flash CS5.5 Tutorial

In Actionscript 2, it is possible to export fonts for Actionscript so that they can be used dynamically at a later date in code. Doing this is very useful, but it can be tricky to set up initially.

To embed a font, first create a new font by right clicking and selecting new font in the library.

Create a new font by right clicking in the library and selecting 'New Font'.

Create a new font by right clicking in the library and selecting 'New Font'.

Create a new font by selecting a family from the drop down menu, embed any required characters and give the font a name.

Embed all required fonts.

Embed all required fonts.

After the font has been created, we now need to click on the ‘Actionscript’ tab at the top and then the ‘Export for Actionscript’ checkbox.

Exporting a font for Actionscript in AS2

Exporting a font for Actionscript in AS2

Finally after this has been done hit the ok button and you should see the following in your library:

Font embedded correctly in the library.

Font embedded correctly in the library.

Now that our font is embedded in the library, we can use the font in our code. Here is an example:


var textFormat:TextFormat = new TextFormat();
textFormat.bold = true;
textFormat.size = 16;
//remember to set the name of the font to the name you set in the library linkage. 
textFormat.font = "Font 1";

//set textfield to the name of your textfield.
textField.setTextFormat(textFormat);
textField.embedFonts = true;