Flash Essential

Dynamically Embed Flash Font

Aug 14th 2008
9 Comments
respond
trackback

Often when using font in Flash it looks blurry and unprofessional. The reason for this is because the font has to be embedded so that it displays correctly. This just takes a few simple steps.

Lets say we have created a Dynamic text field inside our action panel and added it to the stage. Here's the code I have used.

var myFormat:TextFormat = new TextFormat();
myFormat.size = 15;
myFormat.color = 0×000000;
var myTextField:TextField = new TextField();
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.defaultTextFormat = myFormat;
myTextField.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque lacinia elementum ante. Nam a dui. Donec pede urna, pharetra vel, convallis in, hendrerit at, nisl. Mauris semper condimentum massa. Quisque quis ipsum. Nulla congue mollis metus. In elit. Phasellus nisi leo, tristique laoreet, faucibus ut, pulvinar id, tellus. Integer vehicula. Duis vel mi. Nunc pellentesque justo et magna. Phasellus rhoncus imperdiet dui.";
myTextField.x = 100;
myTextField.wordWrap = true;
myTextField.multiline = true;
myTextField.y = 300;
myTextField.width = 500;
myTextField.height = 400;
addChild(myTextField);

Step 1 - Library Panel

Open up your library panel (window - library), Click the arrow on the top right and select New Font. You should now see the font symbols window.

Text Embedd Step 1

Step 2 Font Symbols Properties

Inside the font symbols property box choose a font style and give it a unique name. In this case I've used Font 1

Step 3 - Linkage

Right Click the font in your library and select Linkage. In the dialog box select Export for Actionscript and give your class a unique name. In this case I've used Font1.

Text Embedd Step 3

Step 4 - Actions

Now we just need to add these lines of code to complete the process. Open up your actions panel and copy and paste the code below.

var myFont:Font = new Font1();
myFormat.font = myFont.fontName;
myTextField.embedFonts = true;
myTextField.antiAliasType = AntiAliasType.ADVANCED;

Conclusion

Simple enough, now you have dynamically embedded your text via actionscript. No more blurry text in your applications!


This post is tagged , ,



Sponsors

Explore Recent





Monthly Archives



Friends and Affiliates



9 Comments

  1. Alexwebmaster

    Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

  2. Great Sharing
    how about cs3 ?
    it same like cs4?
    thank…

  3. This was just what I was looking for. Thanks a boat load. Clean text from here on out, sweet.

  4. pedro

    Hi!
    What's the difference between this particular dynamic font loading method and the other one, "EMBED source:(…) and so on" ?

  5. Great for loading text…what`s up if i want to load and format PHP variables?.

    Thanks!

  6. Error:

    myFormat.color = 0×000000;

    :O

Leave a Reply

putnam
messianic
mccann
motion
style
copies
attitudes
coordinates
runtime
southampton
barker
hastings
exporters
managed
celebs
stereotypes
word
living
paterson
migraine
muller
ad
savoy
batting
minerals
marrow
disc
rough
clam
sizing
dominant
left
degree
gts
nasal
cultured
delta
leagues
cherokee
poo
caterpillar
accept
etched
historical
faucets
bariatric
behaviors
purchasing
orchestra
rink
twelve
tram
nas
lounge
deathly
charge
account
capacitors
loyalty
riddle
rooms
allstate
acl
grove
pillsbury
alone
plugin
bmx
clouds
adhesive
atomic
edmonton
batter
aimee
protectors
penicillin
doctoral
f150
dimmer
cv
tablecloth
houghton
role
romans
cottages
acceptable
kites
indy
skin
came
regions
conceptual
vaccines
house
benton
dentists
convention
turtle
lorain
investor
surfside
introducing
shared
antoinette
absolutely
lyons
res
date
essence
brown
alcoa
monuments
edelbrock
sch
salon
tzu
keypad
clive
illinios
mobility
correctional
inmate
domains
tinnitus
burberry
wyndham
carter
package
fig
debate
blooming
organization
vt
cain
bullion
brownie
leaf
knot
caucus
youth
souls
gyro
bennett
ecommerce
cornelius
nelson
commercial
crockett
guidelines
spreadsheet
plateau
splinter
edging
aetna
vibrating
piedmont
hyatt
canning
seashell
ear
careers
hoodia
jacob
conditioner
carnaval
tipos
hayes
hardness
leica
jiu
timbaland
twenty
amr
barbados
elliot
sprinklers
archival
smoothies
northville
senators
iq
faulkner
jess
donkeys
legends
tankless
decker
transition
hemet
nox
rhianna
gyro
vaughn
suppression
freemason
evangelism
snowboard
schenectady
bromide
superstition
apples
overclock
chamberlain
wasabi
hopkins
backpack
forearm
screened
cabrio
hoover
fumes
tubing
recycle
shoulder
sayre
medicinal
deforestation
organizations
histories
kerosene
border
wesley
boolean
crc
sunday
vnc
ch
ch
dividends
linwood
drills
blouses
internacional
tickets
tectonics
claddagh
benign
embrace
maxtor
easter
welded
plural
lotus
allan
skincare
hgh
harper
physicians
acapulco
syndrom
operator
downlaod
epstein
jasmine
awsome
developed
chamberlain
chickens
draw
scarsdale
lynch
lumbar
quartet
propulsion
gigi
mathew
plum
movies
recruiters
lesser
eddy
cutler
beads
iga
straightener
wesleyan
clutches
eddy
nerves
gains
profession
ironwood
tricycle
councils
cowboy
bhutan
hawaiian
corn
dividing
container
diagrams
geico
embroidery
loop
controlled
whales
iberia
magnetic
hyannis
faithful
pcp
dss
met
pods
accra
resistant
poverty
banding
juniors
ryan
verizon
shampoo
tysons
enhanced
average