I'm building a component and need to be able to select fonts from a font list. I have the font list showing up but I'm unsure of what the proper datatype is or how I should be setting it. I've tried String and Font and I seem to be getting an error.
private var _tfFormat:TextFormat;
_tfFormat = new TextFormat();
This will produce an 1067: Implicit coercion of type String to unrelated flash.text:Font.
private var _font:Font = null;
_tfFormat.font = font.fontName;
[Inspectable(type="Font Name", name="font", defaultValue="Arial")]
public function get font():Font
{
return _font;
}
public function set font(value:Font):void
{
_font = value;
invalidate();
}
This gives me a 1065 Variable is not defined.
private var _font:String = "";
var __cls:Class = getDefinitionByName(font) as Class;
var __fnFont:Font = new __cls() as Font;
_tfFormat.font = __fnFont.fontName;
[Inspectable(type="Font Name", name="font", defaultValue="")]
public function get font():String
{
return _font;
}
public function set font(value:String):void
{
_font = value;
invalidate();
}
I feel I'm pretty close and it's something ridiculously easy that I'm overlooking. Any set of eyes would be appreciated. Thanks.