How to embed fonts in Actionscript 3.0 – The easy way
In this tutorial I will teach you how to embed a custom font. Embedding fonts is good practice in case if the person viewing your flash application or website does not have the font installed on their computer.
In your .fla file go to the library menu and select New Font
A font properties menu will show up. Here you can edit the font name and the font. As you can see I have named font to be myFont Plain. This is because the font that Iam embedding is not bold nor italic. You can name it whatever you want but be descriptive to avoid confusion. The Font is named myFont. This is your main name for the font. Below are some checkboxes which help identify the style of the Font. If I style text with myFont, because I left the checkboxes blank the system will use myFont Plain. If I had created another font which was myFont, had its name as myFont Bold and then selected the bold style, I would have a Bold style for myFont. Now when I use myFont, I can use a bold tag around it and the myFont Bold will get shown.
After adding the new font you should be able to see it in your library. Right click on it and select Linkage. In the Linkage properties window check the box that says Export for ActionScript. You can name the class anything you want but make sure you don’t change the Base Class name.
Now go into your .as file. You will need to import the following classes to make this work.
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
Now that we have our classes loaded we will create a text format and a text field and then add the format to the new text field.
var format:TextFormat = new TextFormat();
format.font = ‘myFont’;
format.color = 0×333333;
var myText:TextField = new TextField();
myText.text = ‘Some Filler Text’;
myText.embedFonts = true;
myText.antiAliasType = AntiAliasType.ADVANCED;
myText.setTextFormat(format);
And there you go. You now have textfield using custom font.
Known Problems
-I am using Flash CS3 on my Macbook Pro and I found that if you add a font to your computer in the fonts folder while Flash is open the font may not be displayed. Instead what was happening to me was I was getting a default font. This made me stressed as nobody was having this problem. But all you have to do is close Flash and reopen Flash and your font will work now. There is some refreshing issue that Flash has with this process in CS3.
I will be posting any other issues with possible solutions.
If you liked this post, you might also like…
No comments yet.
No trackbacks yet.
Easy Slider – Powerful and Customizable jQuery Slider Plugin
about 1 year ago - No comments
Recently, I was working on completing my portfolio website. I wanted a slick and impressive way to display my past portfolio work, and I found this little gem known as Easy Slider while surfing the internet.
Easy Slider saved my life. It’s a jQuery image slider that is highly customizable. I recommend it for anyone who More >
Super Clean and Easy Writing in the Sand Photoshop Tutorial
about 1 year ago - 2 comments
After searching fruitlessly for a good Photoshop tutorial on creating a “writing in the sand” effect, I ended up making up my own way – and now I’ll share it with all of you! It creates a very clean and smooth effect and is super easy and fast to complete.
The first step is More >
Awesome Uses of HTML5’s Canvas Tag
about 1 year ago - No comments
With the development of HTML5 and using the Canvas Tag there are a lot of cool things that can be done. Here I have found some of the coolest things done with the canvas tag.
JSNES
The first one that is pretty impressive is a NES emulator. This was developed by Ben Firshman and is of pretty More >
MAC VS PC
about 1 year ago - 2 comments
We all know the stereotypes. Apple’s popular commercials have painted the picture in stark terms: There are two types of people, Mac people and PC people. And if the marketing is to be believed, the former is a hip, sport-coat-and-sneakers- wearing type of guy who uses his computer for video chatting, music mash-ups and other cool, creative More >
How to change a textfields alpha in Actionscript 3.0
about 1 year ago - 1 comment
I am writing this tutorial for anyone who is having any issues with changing the alpha channel with actionscript. I’m gonna show you how. This might seem pretty straight forward at first, I mean I thought it was, but you actually can’t just start changing the alpha property without first setting its blendMode. This sometimes More >
Sublime HTML5 Video Player
about 1 year ago - 1 comment
With HTML5 just around the corner many people are excited as to what this new technology will bring us. One of the coolest parts of HTML5 is the ability to watch video without any plugins what so ever! This means no Adobe Flash or DivX to watch movies on your website! HTML5 is still being More >
Top 10 Web Design Resources Every Designer Should Know About
about 1 year ago - No comments
Where would web designers be without the invaluable resources provided on the web for us? Design inspiration, stock photos, tutorials, fonts, freebies, brushes, textures … the list goes on. Take advantage of the resources and expertise other web designers offer for free! Here are 10 of my absolute favourites, in no particular order:
Design Meltdown (design More >
CSS Custom Font-Face
about 1 year ago - No comments
On the request of my friends, this post will show you how to simply add your own font face to your website using CSS. This comes in handy when you want to display dynamic text on a webpage when the user does not have the font installed on their system. This is a very old More >
GIMP – The FREE Alternative to Photoshop
about 1 year ago - 4 comments
Let’s face it: Photoshop is freakin’ EXPENSIVE. At a whopping $700 US for Photoshop CS4, you had better hope your parents decide to spoil you and buy it for you next Christmas. Unfortunately, the high price point makes it difficult for beginners and aspiring web designers to get into the business – you had better More >
HMTL5 Local Storage, Session Storage, and Client-side Database Tutorial by O’Reilly
about 2 years ago - 1 comment
This tutorial will take you through the new features of HTML5 involving client side storage, sessions and databases. The tutorial is based off creating a web app for the iPhone but will serve you the same purpose if you are looking for any web based platform. HTML5 is the future and its a good idea More >


