Best practice for embedding fonts in AS3.
Fonts can be embedded using the Flex metadata “Embed”.
For example, if you want to embed the font named Arial (this should be the system font located in FontBook or the Fonts folder)
[as3]
[Embed(systemFont="Arial", fontName="Arial", mimeType="application/x-font", unicodeRange="U+0041-U+0054")]
var arial:Class;
Font.registerFont(arial);
[/as3]
systemFont: looks for the current system font with the name “Arial”
fontName: the name used to reference this font inside the code
mimeType: the type of file that i’m embedding, in this case an x-font
unicodeRange: the sample unicode range represents uppercase characters from A-Z (convert unicode easily here)
For best practices, we can compile the file as a swf, and load them at runtime using the loader class. This way we only need to load the file when it’s actually needed.