Embedding Fonts in AS3 Only.

This post details how to embed fonts with only AS3.

Took a good 2 hours to come across the right information. Hopefully somebody else can benefit from this as well.

It looks like if you ever need to change the alpha on a TextField you need to embed the font. Here are the basics.

/// EMBED FONT ///
[Embed(source = "path_to_font", fontName= "myFont")]
public static var myFont:Class;
Font.registerFont(path_to_font_class);
/// CREATE TFORMAT ///
var format:TextFormat = new TextFormat();
format.font="myFont"
/// CREATE TFIELD ///
var tf:TextField = new TextField();
tf.embedFonts = true;
tf.defaultTextFormat = format;

Now you are finally good to go. tf.alpha=0, and sure enough, it works.

3 Comments

  1. jav666 says:

    the “thispost” URI is offline.

    do you have a backup?

  2. Yuji says:

    Looks like it’s gone. I don’ t have a backup, but there is an example in my post : )

Leave a reply to jav666 Cancel reply