Hi,
I solved my problem (and some more, see below)
The wrong line in my code appeared to be:
heading.font = myVerdanaBold.fontName;
I changed it in:
heading.fontFamily = myVerdanaBold.fontName;
and al was well.
The the exact phrase 'fontFamily' is crucial here (but it doesn't
appear as a key word!) !!??
Also it appears that the V3 TextArea component doesn't support
stylesheets.
I found this page:
http://www.sharedknowhow.com/2008/07/fixed-flash-textarea-css-
incompatibility/
It provides a very simple (meaning: understandable, even for me)
explanation + solution.
Even I can apply a stylesheet to a V3 TextArea now. Must be peanuts
for most of you.
cheers
Willem van den Goorbergh
Op 23-jul-2008, om 12:53 heeft Geografiek het volgende geschreven:
Hi list,
I try to format a font in a TextField with the following code:
//@@ instantiate verdanaBold
//@@ in the lib exists a font symbol 'verdanaBold' exported for AS
var myVerdanaBold:Font = new verdanaBold();
//@@ define styleSheet
var mySs1:StyleSheet = new StyleSheet();
var heading:Object = new Object();
var body:Object = new Object();
heading.font = myVerdanaBold.fontName;
//@@ or??
//heading.fontFamily = "verdanaBold";
heading.fontSize = 24;
heading.fontWeight = "bold";
heading.color = "#FF0000";
body.color = "#0000FF";
body.italic = "italic";
mySs1.setStyle(".heading",heading);
mySs1.setStyle("body",body);
//@@ define TextField
var myTxtF1:TextField = new TextField();
myTxtF1.x = 100; myTxtF1.y = 200;
//@@ the following line prevents the text from showing
//@@ if disabled the text shows correct (but for the desired
Verdana of course
myTxtF1.embedFonts = true;
myTxtF1.styleSheet = mySs1;
myTxtF1.htmlText = "<body><span class='heading'>Why </span>is font
handling in CS3 so intimidating??</body>";
addChild(myTxtF1);
I'm doing something wrong in the font assignment department but what??
Thanks,
Willem van den Goorbergh
Finally: (just to vent my frustration, skip this is you want ;-))
Why is it that font handling in CS3 is so @[EMAIL PROTECTED] intimidating?
- There are multiple strategies to make a font available to
TextFields, but not one that seems to be better than others for
general purposes
- You need to apply mutually dependent settings in different places
to get things right
(e.g. create a font symbol *and* export it for AS (why not in the
same window like all other symbols??) *and* assign a value to the
font property of a TextFormat object *and* assign that TextFormat
to a Textfield *and* set myTfld.embedFonts (why is this not a
property of TextFormat. When I define a font there, it's obvious
that I want to embed that font in the textField the textFormat is
assigned to) When one of these settings is incorrect Flash fails
silently in some cases (just displays nothing, no placeholders for
missing characters, no error message, nothing))
- The cs3 help docs contain plain errors (I remember 'myTfld.html'
but this generates an error because the property html doesn't exist
in AS3
- Again in the help docs, in the part explaining style sheets, the
harderst part (defining the font family) is left out of the example
- syntax is inconsistent. When I want to format existing text I
need a method 'myTfld.setTextFormat(myTfmt2)' but when I want to
format text to be added afterwards I suddenly need a property
myTfld.defaultTextFormat = myTfmt2' (where did AS2's
setNewTextFormat() method go?)
- why is the way text in TextArea components is formatted so
different from formatting TextFields
(e.g. myTextArea.setStyle("embedFonts", true) versus
myTfld.embedFonts = true;
and many more ......
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)
30-2719512 or cell phone: (+31)6-26372378
or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)
30-2719512 or cell phone: (+31)6-26372378
or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders