Skip to main content
Inspiring
November 21, 2007
Answered

embedFonts in AS3 class

  • November 21, 2007
  • 10 replies
  • 1825 views
I can't seem to find anything to say whether or not I am to use the Class name given when I export the font for Actionscript. I have done that when setting up my styleSheet but it doesn't seem to be working. Is there something new I've missed with AS3?
This topic has been closed for replies.
Correct answer kglad
did you use "AGBookBQ-Medium" when assigning the font property of your textformat instance?

10 replies

kglad
Community Expert
Community Expert
November 24, 2007
you're welcome.

i don't know of any problem using css with as3. and i don't know moock means.
kglad
Community Expert
Community Expert
November 24, 2007
if you still don't have this working create a new fla with your font and a new fla that loads the fla containing your font and then uses that font.

if you get that working, increase the loading fla's complexity until you're duplicating your original project. if you can't get that first step working, post a link to your fla;s.
aniebelAuthor
Inspiring
November 24, 2007
Ok, got it working. I did have to use the font name as it was originally. I must have had something else off in my code to where it wasn't working before. Here's what I ended up with:

aniebelAuthor
Inspiring
November 24, 2007
Thanks, kglad and Robert! I came up with the solution based on both of your contributions. These things are always a bear but I think I can work with this new information and I really like the encasulation of having a separate swf for fonts only.

What are your opinions on using CSS with these styles? I am reading Moock's book on AS 3.0 and I am interpreting it as he doesn't suggest using it with AS 3.0 since there are more robust ways of formatting text???

THANKS AGAIN!
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 24, 2007
did you use "AGBookBQ-Medium" when assigning the font property of your textformat instance?
aniebelAuthor
Inspiring
November 24, 2007
Weird, I thought I responded to this already...

Yes, I've tried both "AGBookBQ" and "AGBookBQ-Medium".

Also, I noticed that using the stylesheet did not work... that I had to set the font using the FONT tag in the HTML.
Inspiring
November 24, 2007
Can you tell me specifically which font you're trying to use? The class name should not be important, just so long as you refer to the class name in the Font.registerFont() method. Did you read my second article too in the series?
aniebelAuthor
Inspiring
November 24, 2007
I hadn't gotten to the 2nd article yet... will have to go grab my card to do so. :)

The font is AGBookBQ-Medium. It shows up in the output panel (as an embedded font) as "name:AGBookBQ-Medium, style: regular, type: embedded"

The Class name is "AGBookBQ".

This works with Arial. Maybe it's an issue with this particular font despite the fact I had it working in AS2.0.
Inspiring
November 24, 2007
I wrote a couple of tutorials on sharing fonts in AS3 without using runtime shared libraries (new feature in AS3/FP9--no more need for runtime shared libaries!). Here's the series:

http://www.communitymx.com/abstract.cfm?cid=67A61
aniebelAuthor
Inspiring
November 24, 2007
Hi and thanks! I've been researching this all morning and coicidentally, I was just reading your article Robert. I got it working from that but I've only got one problem now. The font I want to use has a hyphen in the font name. When I try to set the linkage for export, it's been suggested to name the Class the same as the font name. Obviously I can't do this because class names cannot have a hyphen in them.

Is there a way around this? When I change the class name, it does not work.
kglad
Community Expert
Community Expert
November 24, 2007
i haven't read this but it looks like this guy has, at least, dealt with the issues i dealth with:

http://www.betriebsraum.de/blog/2007/06/22/runtime-font-loading-with-as3-flash-cs3-not-flex/
kglad
Community Expert
Community Expert
November 24, 2007
no. the font class has a registerFont method.
kglad
Community Expert
Community Expert
November 23, 2007
thanks. happy thanksgiving to you and your family, too!!

p.s. check for info about font registration because i think i recall that was a key step in getting this to work for me.
aniebelAuthor
Inspiring
November 23, 2007
What do you mean about font registration? Do you mean with the manufacturer? If this is what you mean, does it matter with a system font?
kglad
Community Expert
Community Expert
November 22, 2007
i don't have my kglad.com web files with me on my thanksgiving vacation and that's where i used an external swf to store common assets including the font used on my website. and i can't remember exactly what i did, but i do know it was not easy and i seem to remember that i needed to register that font. also, i'd be leery of using the same class name as the font name.
aniebelAuthor
Inspiring
November 22, 2007
Wow, you are dedicated... answering posts while on vacation! Thanks, I'll poke around a bit more and use a different class name for the font. Happy Thanksgiving!
kglad
Community Expert
Community Expert
November 22, 2007
use the font name. i know, it makes no sense, but that's what works.
aniebelAuthor
Inspiring
November 22, 2007
Ok, I've created a new font in my FLA named "Arial" which is the same name as the font, obviously, set it to export for AS which created a class named "Arial" also. Here is the method for creating the tab which contains the textfield with its styling.