New Components For Adobe Flash every week!
Forgot password?
Embedding Fonts in Flash CS4
We’ve been often asked how we embed fonts in out Flash Components, so we’ll do a simple step by step tutorial for Flash CS4 (AS3). We are using a MAC, but the same applies for Windows.
Step 1
Right click on the library and select New Font.
Step 2
After clicking the New Font item, the Font Symbol Properties window appears.
Select the font and the style, give the font a name and a size, and check Export for ActionScript.
Step 3
Create a Dynamic Text Field and give the instance a name. (we used the name txt)
Select the text field and the font you just created.
NOTE: If you embedded the font correctly, a * should appear at the right of the font name in the fonts list, and all embedded fonts are positioned at the top of the list, exactly as in the image below.
Step 4
The last step is to add the ActionScript code in your .as file or in the timeline. In this example we’ll add it in the timeline, although all our Flabell Flash Components use Classes. :)
// AUTO SIZE txt.autoSize = TextFieldAutoSize.LEFT; // SCROLLABLE txt.selectable = false; // MOUSE ENABLED txt.mouseEnabled = true; // HTML text txt.htmlText = "Flabell - New Flash Components Every Week!";
The code should be self-explanatory. You can download the source files here: Flabell – embedding_fonts_in_CS4.
This post has 67 comments | Post your comment
Andrei Potorac
August 17, 2009 at 11:00 pm
That is correct. You need to embed the right property for a particular font.
So if you need it as bold, you import the BOLD version of it.
Replyburgutex
August 19, 2009 at 12:56 pm
Do your products take infos from fonts’ file? If I change name of font and leave a name of Turkish font, do application work?
ReplyAndrei Potorac
August 22, 2009 at 7:41 am
If you embed a Turkish font, it works.
ReplyFlylet
September 21, 2009 at 8:43 pm
Does this work for AS3? It’s asking me to change my AS to 1.0 or 2.0. Can you explain how to do it for AS3? Thanks very much.
Replybobocel
September 22, 2009 at 2:35 am
This is for AS3. ;)
Scott
October 6, 2009 at 8:00 pm
You say this is for AS3 but Flylet is right: Flash CS4 will not let you do this without either changing to AS1 or AS2 or giving a ClassName instead of an identifier.
But if you give a ClassName you have to create a class for the font, and I can’t find info on what properties and/or methods that class needs.
Can you give us an idea how to do this in AS3?
ReplyAndrei Potorac
October 11, 2009 at 10:44 pm
Well, the above example is for CS4, AS3 – and as you can see it works properly. No need for a separate class.
Replydave
September 15, 2010 at 10:15 am
You said “this is for AS3. ;)”
Actionscript 3 replaced using identifiers with Class names.
This tutorial uses actionscript 2.0 or lower.
bobocel
September 18, 2010 at 1:41 pm
Nope, it is for as3. :)
Angel
March 29, 2011 at 10:06 pm
Hi … First, thank you Andrei for doing this. Youre doing us all a HUGE favor by sharing your knowledge.
Ive uploaded a screenshot of the Font Symbols Properties window here…. www.eliteeventscompany.com/images/no_id.jpg … so you can see what Im seeing.
Can you help?? ~Angel
Angel
March 29, 2011 at 10:08 pm
Oh, I forgot to mention that I tried this with other fonts as well, and I get the same problem… no Identifier field available.
corneliu.chitanu
March 30, 2011 at 11:22 pm
Yes, the identifier field is enabled only when an AS1 or AS2 project is created.
For AS3 you’ll need to just enter a Class name for the font and set the Base class to “flash.text.Font”. After you hit OK, you’ll find the font named the way you wrote under the Class name, with a “*” (star character) at the end.
If you don’t use runtime sharing, you can uncheck that checkbox at the bottom.
I hope this is helpful and you’ll enjoy the fonts in Flash.
Matt
November 8, 2009 at 5:25 pm
This works slightly for me in CS4 (my text no longer vanishes) however it still wont display a bold version of my font.
I have imported both bold and regular versions of a font, the display as expected in the authoring environment, (and preview of the font) but on publish both appear as regular.
This is slightly better than the text vanishing but still dosn’t give me bold.
Replybobocel
November 9, 2009 at 2:49 am
For bold text, you need to do the same thing, but make sure you give the font a different name, and select the bold property.
Like.. ArialBold for example. Same goes for italic.
Replyfosforo
October 9, 2010 at 10:35 am
For bold text, you need to do the same thing, but make sure you give the font a different name, and select the bold property.
Like.. ArialBold for example. Same goes for italic.
I have the same problem as Matt. I did it all but bold doesn’t show in my htmlText. If all the field is bold I see it, so I think bold’s embed. But if my html has a tag, everything’s regular. Any ideas?
Thank’s in advanced.
Assis
November 11, 2009 at 12:25 pm
I work, loading swf files into my main flash, to incorporate the font, in all, it is cleared when I load a new swf, which has the same font!
why this happens?
what is the correct way to work with font in several SWF files?
I’m creating a symbol and exporting to other swf!
Replybobocel
November 14, 2009 at 12:19 am
Not sure how you do it. But this is the way we do it and it works flawlessly.
ReplyKreyj
November 19, 2009 at 2:02 pm
I’d sweetie to be aware that too!
ReplyTrevor
November 24, 2009 at 2:49 pm
Thank you bobocel for the post!
It was straight forward and exactly what I needed…you are a gentleman and a scholar.
ReplyAutumn
November 25, 2009 at 5:42 am
You only need to embed fonts for dynamic and input fields for Flash CS4 / Actionscript 3.0 right?
ReplyAndrei Potorac
November 25, 2009 at 11:33 pm
No, this was needed for CS3 with AS2 as well.
ReplyRoy
December 1, 2009 at 2:42 am
Hi i’m trying to follow this Tutorial but the problem is that I can’t name the identifier since Flash won’t let me.
Why not? How did you do it?
I have Flash cs4 and a document AS3.
Hope to hear from you soon.
regards,
Roy
bobocel
December 3, 2009 at 3:24 am
Roy, what do you mean Flash doesn’t late you set the name?
ReplyKimhang
December 5, 2009 at 8:03 am
I got more and more complicated with the fonts, I used khmer Unicode (www.khmeros.info) at the begining it’s ok but when i try to get from xml and show in the list nothing character.
Replybobocel
December 14, 2009 at 3:38 am
Please email us the file so we can see what you did.
ReplyKen
January 7, 2010 at 6:53 am
In Flash Mp3 Player, I write unicode xml file by vietnamese but it could not display. Do I have to change font in source flash? Or anyway to resolve this problem?
Please help.
ReplyHoaiNhan
January 8, 2010 at 10:36 pm
Hi Ken, I have succeeded in implementing displaying Vietnamese in uft-8 coded XML. You have to embed Verdana font in every text field from the source file then export the new player. So follow the above for embedding the new font then go to library of source and embed text field with Verdana font one by one. Hope this can help you
Regards
Ken
January 11, 2010 at 12:43 am
Hi Hoai Nhan,
I did but it’s happened some errors. Can you send me your email with your changed flash that I check it?
My email: [email protected], admin cakhucvietnam.com. Thanks for your help.
HoaiNhan
January 12, 2010 at 1:06 am
Hi Ken,
I just sent it to ur gmail account. Look at my homepage: www.lotusmedia.net to see how I have implemented
Fome
January 8, 2010 at 3:13 pm
I am using Flash CS4 (AS3.0) on Windows. The “Identifier” field is disabled, only “Class” and “Base Class” fields are enabled. If i specify the “Class” the text is not displayed any longer. What’s wrong?
Replybobocel
January 9, 2010 at 8:09 am
I’m not sure I follow you. Did you follow the steps described above precisely?
Fome
January 11, 2010 at 2:46 pm
well i tried to follow it precisely, but as Scott wrote, using AS3.0 i cannot specify the “Identifier” for linkage as described in the example as the field is disabled. Only “Class” and “Base Class” fields can be edited. If I use the “Class” field to specify the id, then it’s not going to work, i.e. no text is displayed by banner rotator.
Replybobocel
January 12, 2010 at 12:35 am
Ok, I checked and some fonts don’t allow for an identifier, but there’s no issue, don’t add one.
The remaining steps remain available. Let me know if you have any other issues.
Mindy McAdams
March 16, 2010 at 6:15 am
This is a wonderful post. Thanks so much. My embedded font text was visible when the SWF was viewed on a Mac, but on Windows, it disappeared. (This might have been a Flash Player version issue — I don’t know.) Luckily I had read your post here, and it solved the problem.
Note that my problem concerned a dynamic text field ON THE TIMELINE — I had embedded the font in the old way (using only the Properties panel). The ActionScript in the SWF is changing the text when a button is clicked.
So even though I was not using a Flash Component, I had to use the technique you have documented here.
ReplyAaron
March 29, 2010 at 7:19 am
This works good if I am putting the text field on the stage manually but what if I am building the text field in a class file? Say I created my own butt
Senthil
August 17, 2009 at 10:05 am
But when you embed fonts and try to apply bold or italics through formating which never works, have you ever tested it
Reply