Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : Dynamic Text Field Font Strangeness


JasonWood
9/27/2004 8:42:35 PM
I'm using static text fields and dynamic text fields in a project to display
text. I have set them to a standard font (Tahoma) at 12 points with Aliasing
enabled for easy readability.

The problem I've encountered is that Flash refuses to allow the dynamic text
fields to display any other font besides a Times-Roman looking one in the
project.

What's really strange is that if there are no static text boxes in the
timeline, the dynamic text field renders the Tahoma aliased just fine.

I've tried to embed the font, and that works to a degree but I'm still having
trouble forcing flash to display it aliased.

I've attached 2 tiny samples showing the odd behavior of the static/dynamic
text fonts.

Thanks!

-Jason
EdMX
9/28/2004 4:38:45 PM
Use 'Embed font outlines' under the 'Character' button on the properties tab
and make sure you have the appropriate character sets embedded. - this is why
the text in 'problem-a' fails to appear. As for why it does manage to appear
correctly in 'problem-b', well strangeness indeed.

There is very little logic in the way Flash uses (and more often fails to use)
embedded fonts. And it's true the static / dynamic / embedded / non-embedded
properties of one text box does seem to affect other text boxes on the stage
in a seemingly random way. This bug is currently being ignored by Macromedia -
too interested in video (buy a DVD guys!).

I've found a few hacks which help (a bit) to stop Flash 'going random' with
fonts:
1) Put a second dynamic text box (or a few of them if you use Bold / italic -
one for each style) somewhere on the _root timeline of the stage, making sure
it contains some text in the appropriate style, but do not populate it
dynamically. This hack seems to help Flash to embed a particular font and style
and often does the trick.
2) Make sure there is some text in your original dynamic text box before the
new text is dynamically set.
3) Experiment with anti-aliasing turned on or off. This setting often makes no
difference at all to the final rendering (yet another bug?) except sometimes
when it makes text disappear or if you're lucky, appear in a totally unsuitable
font.
4) Don't use 'New font...' symbols (they're hidden in the library). as they
often seem to make fonts disappear altogether.
speedlab1
9/28/2004 5:07:50 PM
Embleding Fonts with Dynamic TextFields.

1) In your Library add a "New Font", select the appropriate font and
properties, such as bold, italitic or anti-alias, set the point size and give
it an alias name, such as "arial10". Once it has been added to your library, go
into it's linkage properties and select "Export for Actionscript", the
identifier can be the same as the font name "arial10".

2) create a new text format. eg:
var myFormat:TextFormat = new TextFormat()
myFormat.font = "arial10";
myFormat.size = 10
myFormat.color = 0x000000

Add any other properties you'd like

notice the font is not Arial, rather it is the identifier linked in your
Library.

3) create an new text field, eg. this.createTextField() (add parameters to
suit your needs)
this.myText_txt.text = "testing"
this.myText_txt.selectable = false;
this.myText_txt.embedFonts = true; (add any other properties you need

this.myText_txt.setTextFormat(myFormat)


Hope this helps.

AddThis Social Bookmark Button