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:

Actionscript:
  1. var helve:Font = new Helve();
  2. buttonLabel = new TextField();
  3. txtFormat = new TextFormat();
  4. txtFormat.font = helve.fontName;
  5. txtFormat.color = 0x000000;
  6. txtFormat.size = 14;
  7. buttonLabel.embedFonts = true;
  8. buttonLabel.text = "place label text here";
  9. buttonLabel.setTextFormat(txtFormat);

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.

7 Responses to “Using embedded fonts in Flash CS3 using ActionScript 3”

  1. roy Says:

    where your class?

  2. Drew LeSueur Says:

    Thank you!

  3. John David Eriksen Says:

    Thanks, this was a lifesaver :]

  4. Iangregory Says:

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

  5. BSN Says:

    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. Ben Says:

    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();
    addChild(buttonLabel)
    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. mockanator Says:

    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;
    poloroidOviText.setTextFormat(poloroidOviTextFormat);

Leave a Reply


Close
E-mail It