Another day, another fight with Flash
August 13, 2006
Today once again I was confronted with strange Flash behaviour. This time the struggle was about using CSS style on html text in a Flash TextField using an embedded font. I hope I help someone with writing down what I found out.
Okay the problem was this. When using an embedded font in combination with a TextField.StyleSheet, part of my html text disappeared. I solved this by specifying for each HTML tag the font to be used. This is part of what my CSS initialization looked like:
var globalCSS:TextField.StyleSheet = new TextField.StyleSheet();
globalCSS.parseCSS(“a:link {color: #1b5085; font-family: Frutiger55_Bold_Font; font-weight: bold; text-decoration: none; } a:hover {color: #1b5085; font-family: Frutiger55_Bold_Font; font-weight: bold; text-decoration: underline; } b { font-family: Frutiger55_Bold_Font; font-weight: bold; } i { font-family: Frutiger55_Font; } ul { font-family: Frutiger55_Font; } li { font-family: Frutiger55_Font; } .blogHeader { font-family: Frutiger55_Bold_Font; font-size: 14; } .blogDate { font-family: Frutiger55_Bold_Font; font-size: 10; }”);
The font names that I used for the “font-family” CSS property correspond to the library linkage identifier for “export for ActionScript”. (You can set this by right clicking on your embedded font in the library and checking the checkbox “export for ActionScript”.) As you see I included a separate ‘regular’ (Frutiger55_Font) and ‘bold’ (Frutiger55_Bold_Font) font. Just to display parts of the text bold and others not. This was necessary in my situation, but I’ve seen fonts that did not require this. Hope this is of some help to someone. It would have saved me a lot of frustration if I had found something similar!



August 16, 2006 at 7:13 am
he, that looks pretty shocking!
best,
Daan
September 3, 2006 at 4:39 pm
THANKS!!!
I just spent a few hours fighting with this one, and you saved what is left of my hair.
The linkage property for the embedded font was the key!
I never even thought of it.
The “adobe” documentation is less then clear/complete.
josh
September 3, 2006 at 5:00 pm
Hi Josh,
I’m glad I saved some of your hair
)
The “adobe” documentation is far from complete, I hope the product and the documentation will become better.
The frustrating thing about working with Flash now is that some “trivial” things like figuring out how to use an embedded font can take hours! And most of the time the only way to find your solution, is not to think logically, but by trying all a-logical solutions Google brings up (and combinations thereof). I’ve had a lot of fights with Flash, but those about fonts where my worst. I solved some mysteries regarding fonts, feel free to ask help if you encounter more font-related- or other Flash/ActionScript problems, I might know solutions (read: work-a-rounds/hacks
September 7, 2006 at 5:12 am
You saved my ass. I was going crazy trying to figure out why embedded fonts never showed up in my project… The official documents for Flash are truly worthless.
October 20, 2006 at 8:02 am
Good that I found this post, saved some time!
February 19, 2007 at 12:26 pm
Thankyou for this post. Was bugging me why my text kept on disappearing!
April 18, 2007 at 3:28 pm
Thanks for this,
I want do what you have done – use a css to import font information and have the textField use embedded fonts AND embed some of the characters to get the good sharp text rendering. But when i do the last bit – no fonts are displayed.
Any ideas?
Thanks,
Peter
September 19, 2007 at 9:15 pm
Have you had any success using embedFont with a dynamically created textfield in a class definition for use in an .swf? I can’t seem to get embedFonts working if it is declared in my class file, despite having the font embedded properly in the .fla that calls the class.
I am using AS 2.0.
Thanks,
David
November 11, 2008 at 5:42 pm
THANK YOU! You pointed me in the direction of the solution to my problem, which was that my TextField kept disappearing whenever I tried to apply a StyleSheet to it. Turning off font embedding completely did the trick for me!