1 CommentMay 26 | 2009

Simple class to include dynamic fonts in your flash movie. You can either compile this from your fav AS editor or apply it to an FLA as the document class.

To access the fonts, all you will need to is load in the generated swf into your project and use the fontName value you specify in the class to apply the appropriate font.

It’s also good practice to limit the unicode range to characters you need. Adobe provides a good reference, flash-unicode-table.xml, which you can find inside the Flex SDK 2/frameworks folder.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package {
   
    import flash.display.MovieClip;
    import flash.text.Font;
   
    public class Fonts extends MovieClip {
        [Embed(source='C:/WINNT/fonts/DiCnBd.ttf', fontName='_dinBold', unicodeRange='U+0021-U+007A,U+00BB,U+00A9,U+2122,U+00AE')]  
        public static var _dinBold:Class;
        Font.registerFont(_dinBold);
        trace("_dinBold LOADED");
       
        [Embed(source='C:/WINNT/fonts/arial.ttf',fontName='_Arial', unicodeRange='U+0021-U+007A,U+00BB,U+00A9,U+2122,U+00AE')]  
        public static var _Arial:Class;
        Font.registerFont(_Arial);
        trace("_Arial LOADED");
       
        [Embed(source='C:/WINNT/fonts/arialbd.ttf', fontWeight= "bold",fontName='_ArialBold', unicodeRange='U+0021-U+007A,U+00BB,U+00A9,U+2122,U+00AE')]  
        public static var _ArialBold:Class;
        Font.registerFont(_ArialBold);
        trace("_ArialBold LOADED");
       
    }
}
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Ma.gnolia
  • Tumblr
  • TwitThis
  • StumbleUpon