سؤال

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?

هل كانت مفيدة؟

المحلول

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

var font:NumberFont = new NumberFont();
var tFormat:TextFormat = new TextFormat(font.fontName);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top