AS3: Using embedded fonts with components in Flash CS3

(I don’t recommend using the Adobe components, but sometimes shit hits the fan)

First, create a new font in the library (e.g. with id MyFont).
IMPORTANT: This is the one thing that prevented it from working at first. When you embed a font in the library, “Bitmap Text” is checked by default. When this was checked, TextFields behaved like device fonts - I couldn’t set an alpha on them. Uncheck it!

This will set the global style for all components:

StyleManager.setStyle( "textFormat", new TextFormat("MyFont") );
StyleManager.setStyle( "embedFonts", true );

There are a lot of real slick examples out there that use the Embed metadata to embed the font directly from the font file. This doesn’t work in CS3 - only Flex…


About this entry