Skip to main content
Known Participant
June 7, 2013
Answered

Embeding Fonts in AS3?

  • June 7, 2013
  • 1 reply
  • 1751 views

Hello All,

Publish Settings:

     Program:  Flash Professional CS6

        Target:  Flash Player 11.2

         Script:  Actionscript 3

    

So I've created 2 new "Fonts" in my library in order to embed them into my Program. But when I run the program the font is not correct. Not sure

what I'm doing wrong..?

Below are the settings for the Embedded Fonts I included. There are 2 of them, which I created by right-clicking in the Library and clicking "New Font".

The First Font:

                       Name:  "Font_Impact" 

          Char Ranges:  All

       Outline Format:  TLF(DF4)

                Linkage:

                      -     Checked --->  Export for Actionscript

                      -     Checked --->  Export in Frame 1     (*Don't know if I needed this but it was selected by default..??)

                      -     Identifier --->  Greyed out....

                      -           Class --->  "Font_Impact"

                      - Case Class --->  "flash.text.Font"
                Sharing:

                         *NOTHING SELECTED HERE (*This was the default so I left it as is)

The seconds font has the exact same settings as the one above except:

               Name:  "Font_Arial_Black"

               Class:  "Font_Arial_Black"

Now, what I did was I followed the instructions I found here at this link below:

          http://www.gaslightgames.co.uk/?p=163

I think I did exactly what they did in their example but it didn't seem to work for me.

My code where I'm trying to use this is:

import flash.text.TextField;

import flash.text.Font;

import flash.text.TextFieldAutoSize;

import flash.text.TextFormat;

import fl.text.TLFTextField;

    var tickerTxtField:TLFTextField = new TLFTextField();

    //var tickerTxtField:TextField = new TextField();               //---> Tried this one too, same result

var tickerTxtField_format:TextFormat;        //TextFormat

var embedFont:Font_Arial_Black;               //Embedded Font 1

var embedFont2:Font_Impact;                    //Embedded Font 2

:....

:............OTHER CODE............:

:............

embedFont = new Font_Arial_Black();

embedFont2 = new Font_Impact();

tickerTxtField_format = new TextFormat();

tickerTxtField_format.font = embedFont.Font_Impact;

tickerTxtField.text = "This is some sample Text To Display..."

:....

:............OTHER CODE............:

:............

I thought I was doing it correctly while I was following the instructions in the link I provided, but I can't seem to get it working.

Can anyone tell what I'm NOT doing correctly? Any thoughts would be greatly appreciated...!

Thanks in Advance,

Matt

This topic has been closed for replies.
Correct answer

Hi,

I believe this line is the one causing problems:

tickerTxtField_format.font = embedFont.Font_Impact;

I guess it should be:

tickerTxtField_format.font = embedFont.fontName;

You actually want to use the property 'fontName' of the Font class, not substitute it for the name of your font.

Hope it helps,

Marcel

1 reply

Correct answer
June 7, 2013

Hi,

I believe this line is the one causing problems:

tickerTxtField_format.font = embedFont.Font_Impact;

I guess it should be:

tickerTxtField_format.font = embedFont.fontName;

You actually want to use the property 'fontName' of the Font class, not substitute it for the name of your font.

Hope it helps,

Marcel

mrm5102Author
Known Participant
June 10, 2013

Hey shiftless, thanks for the reply!

Oh, ok... I thought it was weird to use the font name that "I" gave to it. So that makes sense.

I'll give that a try and post back with my results.

Thanks Again for the reply,

Matt