0

I have a font I want to apply to a TextField, but before I could do that, it threw an undefined error. Here is my code:

var tFormat:TextFormat = new TextFormat();
trace(NumberFont);

which traces [class NumberFont] without problems, but I understand that I need a String, not a class to set the TextField font.

When I try to get the name: trace(NumberFont.fontName);

it gives a compiler error

1119: Access of possibly undefined property fontName through a reference with static type Class.

The code seems basic, but I am totally unfamiliar with TextFormat. What am I doing wrong?

user2956947
  • 239
  • 1
  • 2
  • 12

1 Answers1

0

You should instantiate the font and access the fontName instance property:

var font:NumberFont = new NumberFont();
var tFormat:TextFormat = new TextFormat(font.fontName);
nordhagen
  • 799
  • 5
  • 18
  • Of course! I have to access an object rather than class. It doesn't throw an error, but it still doesn't show the text in a different font. – user2956947 May 08 '14 at 20:28