views:

318

answers:

1

Hi der!

I'm using some fonts embedded in SWF in a program I'm developing. I need to use some specific font style like '37 Thin Condensed' and '26 Ultra Light Italic' etc... how can I specify these style when using fonts? I want to set style using AS3 code...

A: 

An example for Helvetica Neue 37 Thin Condensed

In your Library panel, in the top right corner, click for the drop down and choose "New Font."

For the name field, put "HelveticaNeue37ThinCondensed", for the the font field, choose "Helvetica Neue," for the style field choose "37 Thin Condensed." If you see a button on the bottom right labeled "Advanced" click it.

Under "Linkage" check "Export of ActionScript," and make the class field match the name field from above: "HelveticaNeue37ThinCondensed."

Click OK.

Now you can apply the font in ActionScript:

var font1:Font = new HelveticaNeue37ThinCondensed();

var tfoBodyText:TextFormat = new TextFormat();
tfoBodyText.font = font1.fontName;

var tfiBodyText:TextField = new TextField();
tfiBodyText.embedFonts = true;
tfiBodyText.defaultTextFormat = tfoBodyText;
tfiBodyText.text = "This is some text for the new text field.";

addChild(tfiBodyText);