Using embedded fonts in Flash CS3 using ActionScript 3

I just thought  I’d make a quick post about how to use embedded fonts in Flash CS3 using ActionScript 3 because I had to do that last week and I did really know how to do it. Well it starts just as you did in Flash 8, you right click in the library and you choose New Font… Then choose the font you want to embed and click Ok. Now you’ll have to right click on the new font in the library and choose linkage. In the pop window, click export for ActionScript and give it a class name. Once that is done you can use that font in any textfields you create  with ActionScript.

Here is code showing you how to do it:

var helve:Font = new Helve();
buttonLabel = new TextField();
txtFormat = new TextFormat();
txtFormat.font = helve.fontName;
txtFormat.color = 0x000000;
txtFormat.size = 14;
buttonLabel.embedFonts = true;
buttonLabel.text = "place label text here";

My font class name in the library was Helve. I use the TextFormat object to set the font for the textfield, it’s that easy.

, ,

  1. #1 by roy - March 27th, 2008 at 22:54

    where your class?

  2. #2 by Drew LeSueur - April 19th, 2008 at 15:06

    Thank you!

  3. #3 by John David Eriksen - April 25th, 2008 at 14:11

    Thanks, this was a lifesaver :]

  4. #4 by Iangregory - July 8th, 2008 at 21:36

    Thanks. Helps a lot.
    Roy, his class is in the first line.

  5. #5 by BSN - July 24th, 2008 at 22:19

    The class is *not* in the first line. An instance of the Helve Class is created on the first line.

    The class is generated automatically by Flash when the .swf is compiled. The author wrote: “In the pop window, click export for ActionScript and give it a class name.” When you close the linkage dialog, Flash will tell you that it can’t find the specified class, but it will kindly create it for you on compilation. The generated class is then embedded into the .swf, but unless you decompile it, you’ll never see it…

  6. #6 by Ben - August 13th, 2008 at 16:49

    Wish I found this 2 hours ago – thanks though I think this should read as having the var and class named the same caused an error

    var _helve:Font = new helve();
    var buttonLabel = new TextField();
    var txtFormat = new TextFormat();
    txtFormat.font = _helve.fontName;
    txtFormat.color = 0×000000;
    txtFormat.size = 14;
    buttonLabel.embedFonts = true;
    buttonLabel.text = “place label text here”;
    buttonLabel.setTextFormat (txtFormat);

  7. #7 by mockanator - November 7th, 2008 at 19:34

    I keep getting 1119: Access of possibly undefined property FATTIP through a reference with static type flash.text:Font.

    when trying…

    var poloroidOviTextFormat:TextFormat = new TextFormat();
    var fatTipFont:Font = new FATTIP();
    poloroidOviTextFormat.size = 24;
    poloroidOviTextFormat.color = 0×000000;
    //debug ///////////////////////////////////////////////////////////////
    if (debug) {
    debugText.appendText(String(fatTipFont) +”font \n”);
    //End debug ///////////////////////////////////////////////////////////////
    poloroidOviTextFormat.font = fatTipFont.FATTIP;

  8. #8 by Sakana - December 31st, 2008 at 09:47

    Thanks for this article;

    But how to manage the embed font from an external html text.

    I mean. I have an external xml with html text, that use various font. The font are in my library but when I use the html font face to change my font nothing happen… any idea ?

    Happy new year.


  9. #9 by Sebastian - January 14th, 2009 at 08:38

    Hey there ! do you have a workaround for special characters? Registering a font with this embed solution is simple but accesing special characters and glyphs … UNICODE based elements like latin special characters is difficult. Do you know a way to do it, becuase there’s no point to use embed fonts if he actually gives you just a small amount of characters .
    Thanks in advance.

  10. #10 by Atul - January 20th, 2009 at 10:33

    is it possible to apply the embedded font from css file?

  11. #11 by John - May 26th, 2009 at 08:34

    How to refer to an embedded font in an external class imported in the main flash movie?
    var helve:Font = new Helve();

    1180: Call to a possibly undefined method Helve

  12. #12 by paulo - September 23rd, 2009 at 12:55

    had a problem with formating text and this allowed me loads.

  13. #13 by Stephen - March 29th, 2010 at 14:34

    Thanks for posting I didnt know you had to give it a linkage name. Saved me alot of hassle.


  14. #14 by Søren Larsen Pedersen - May 20th, 2010 at 16:56

    @John & paulo:

    I just did something like this:

    public var headerText:TextField = new TextField();

    private var fTimes:Font = new fontTimes();

    with (headerFormat)
    color = 0×000000;
    font = fGill.fontName;
    size = 16;
    bold = false;

    with (headerText)
    defaultTextFormat = headerFormat;
    x = 0;
    y = 0;
    embedFonts = true;
    antiAliasType = AntiAliasType.ADVANCED;
    border = false;
    width = 100;
    height = 20;
    selectable = false;
    wordWrap = true;
    text = “Default”;

    I hope it helps.

    P.s. Remember what Ben said:
    “… having the var and class named the same caused an error”

  15. #15 by nadim - March 29th, 2011 at 10:33

    Great. Thx Ben & Søren Larsen Pedersen – keeping the var and class name different workerd for me. Thx ;-)

  16. #16 by Chase - May 2nd, 2011 at 17:49

    This is awesome. Thank you!

  17. #17 by Jasper Vandegaer - May 28th, 2011 at 16:52

    Thx. Really good and easy to understand! It helped me a lot :) keep on posting ;)

(will not be published)
Subscribe to comments feed

Parse error: syntax error, unexpected ';' in /homepages/25/d169645162/htdocs/wp-content/themes/fusion/footer.php on line 13