How to use dynamic fonts on html using AS3

Most designers find themselves worrying about cross-browser compatibility. Most of the time, they have to work with a limited choice of fonts.

What if you want to do something flashy, like this:

Notice the gradient and the drop shadow in the “Company” header. It’s done in flash. And since it’s Blizzard, I assume it runs under a CMS so it’s dynamic. You can change “Company” to “Kompanya” just as easily.


1. Design whatever wonderful dynamic text you want in flash.

2. Make sure you embed the characters you want included in the font.

3. Assuming your instance name is “textMC”. Put this in the main timeline:


var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var _text:String = String(params["content"]);
var _orientation:String = String(params["align"]);

var myTextFormat:TextFormat = new TextFormat();
if(_orientation == "center"){
myTextFormat.align = TextFormatAlign.CENTER; //align center
}else if(_orientation == "right"){
myTextFormat.align = TextFormatAlign.RIGHT; //align right
myTextFormat.align = TextFormatAlign.LEFT; //default alignment is left

textMC.text = _text;


4. In your embed code, specify “content” and “align” in the params. “content” contains your content. If you want to set the alignment set “align” to “center” or “right”. The text aligns to the left by default. Ex:

content="This is the content"

Call setTextFormat() only after you set the text. Flash needs to know the content first, before it can properly format the textfield.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: