all groups > flash actionscript > august 2004 >
You're in the

flash actionscript

group:

css & embedding fonts


css & embedding fonts j_red
8/31/2004 5:47:16 PM
flash actionscript: hey - i would like to take advantage of the css support in flash, but i would
like to use a specific font as well - is there a way to to something similar to
the effect of embedding the font, then changing the font color/size? If you
'embed fonts' on a text field the css won't show up...

basically i would like to use a specific font on all browsers and then format
it with css.

thanks.
Re: css & embedding fonts j_red
9/1/2004 3:31:40 AM
Re: css & embedding fonts dedannon
8/12/2005 10:55:55 PM
it's possble. what i do is create a dummy textfield with the same font and make
sure i embed the characters range that i need through the properties window.
after that you're free to format your text with textFormat or CSS.

---
Dedannon
Re: css & embedding fonts SteveStall
8/13/2005 12:25:26 AM
And how do you refer to the fonts name in the tag "font-family" =
parameter?
SteveStall




[quoted text, click to view]
it's possble. what i do is create a dummy textfield with the same font =
and make=20
sure i embed the characters range that i need through the properties =
window.=20
after that you're free to format your text with textFormat or CSS.

---
Dedannon
Re: css & embedding fonts dedannon
8/15/2005 9:35:52 PM
If you're writing the css script within flash you write fontFamily: 'Font
Name'. Here's an example:

var mainTextCSS = new TextField.StyleSheet();
mainTextCSS.setStyle('bodyText',{
fontFamily: 'Arial',
fontSize: '12px',
color:'#ff0000'
});

If you're loading an external stylesheat you write it as you would with
regular xhtml

bodyText{
font-family: 'Arial';
fontSize: '12px';
color:'#ff0000';
}

In order to load the external stylesheet you need to attach it to a stylesheet
object

var mainTextCSS = new TextField.StyleSheet();
mainTextCSS.load("pathToStylesheet");
mainTextCSS.onLoad(ok){
if(ok){
//text code here...
}
}

If you've created a dummy textfield with the selected font and embeded the
characters you need through the properties window the following code will do
the trick:

this.createTextField("text_txt", this.getNextHighestDepth(), 0, 0, 100, 100);
text_txt.html = true;
text_txt.embedFonts = true;
text_txt.styleSheet = mainTextCSS;
text_txt.text = "<bodyText>text</bodyText>";

However, the dummy text will need to have the same basic properties as the CSS
style you're writing. Normal characters in the dummy textfield wont be enough
if you need bold characters in your stylesheet etc.

Hope this will help:)

DeDannon
AddThis Social Bookmark Button