13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Using the TextField class<br />

Advanced text r<strong>en</strong>dering<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

ActionScript 3.0 provides a variety of classes in the flash.text package to control the properties of displayed text,<br />

including embedded fonts, anti-aliasing settings, alpha channel control, and other specific settings. The ActionScript<br />

3.0 Refer<strong>en</strong>ce provides detailed descriptions of these classes and properties, including the CSMSettings, Font, and<br />

TextR<strong>en</strong>derer classes.<br />

Using embedded fonts<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

Wh<strong>en</strong> you specify a specific font for a TextField in your application, Flash Player or AIR look for a device font (a font<br />

that resides on the user’s computer) with the same name. If it doesn’t find that font on the system, or if the user has a<br />

slightly differ<strong>en</strong>t version of a font with that name, the text display could look very differ<strong>en</strong>t from what you int<strong>en</strong>d. By<br />

default, the text appears in a Times Roman font.<br />

To make sure the user sees exactly the right font, you can embed that font in your application SWF file. Embedded<br />

fonts have a number of b<strong>en</strong>efits:<br />

Embedded font characters are anti-aliased, making their edges appear smoother, especially for larger text.<br />

You can rotate text that uses embedded fonts.<br />

Embedded font text can be made transpar<strong>en</strong>t or semitranspar<strong>en</strong>t.<br />

You can use the kerning CSS style with embedded fonts.<br />

The biggest limitation to using embedded fonts is that they increase the file size or download size of your application.<br />

The exact method of embedding a font file into your application SWF file varies according to your developm<strong>en</strong>t<br />

<strong>en</strong>vironm<strong>en</strong>t.<br />

Once you have embedded a font you can make sure a TextField uses the correct embedded font:<br />

Set the embedFonts property of the TextField to true.<br />

Create a TextFormat object, set its fontFamily property to the name of the embedded font, and apply the<br />

TextFormat object to the TextField. Wh<strong>en</strong> specifying an embedded font, the fontFamily property should only<br />

contain a single name; it cannot use a comma-delimited list of multiple font names.<br />

If using CSS styles to set fonts for TextFields or compon<strong>en</strong>ts, set the font-family CSS property to the name of the<br />

embedded font. The font-family property must contain a single name and not a list of names if you want to<br />

specify an embedded font.<br />

Embedding a font in Flash<br />

Flash Professional lets you embed almost any font you have installed on your system, including TrueType fonts and<br />

Type 1 Postscript fonts.<br />

You can embed fonts in an application in many ways, including:<br />

Setting the font and style properties of a TextField on the Stage and clicking the Embed Fonts checkbox<br />

Creating and refer<strong>en</strong>cing a font symbol<br />

Creating and using a run-time shared library containing embedded font symbols<br />

Last updated 6/6/2012<br />

384

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!