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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Using the TextField class<br />

p {<br />

}<br />

font-family: Georgia, "Times New Roman", Times, _serif;<br />

font-size: 12;<br />

leading: 2;<br />

text-align: justify;<br />

ind<strong>en</strong>t: 24;<br />

h1 {<br />

font-family: Verdana, Arial, Helvetica, _sans;<br />

font-size: 20;<br />

font-weight: bold;<br />

color: #000099;<br />

text-align: left;<br />

}<br />

h2 {<br />

font-family: Verdana, Arial, Helvetica, _sans;<br />

font-size: 16;<br />

font-weight: normal;<br />

text-align: left;<br />

}<br />

The technique used to read the external CSS file is the same as the technique described in “Loading an external CSS<br />

file” on page 381. Wh<strong>en</strong> the CSS file has be<strong>en</strong> loaded the application executes the onCSSFileLoaded() method, shown<br />

below.<br />

public function onCSSFileLoaded(ev<strong>en</strong>t:Ev<strong>en</strong>t):void<br />

{<br />

this.sheet = new StyleSheet();<br />

this.sheet.parseCSS(loader.data);<br />

}<br />

h1Format = getTextStyle("h1", this.sheet);<br />

if (h1Format == null)<br />

{<br />

h1Format = getDefaultHeadFormat();<br />

}<br />

h2Format = getTextStyle("h2", this.sheet);<br />

if (h2Format == null)<br />

{<br />

h2Format = getDefaultHeadFormat();<br />

h2Format.size = 16;<br />

}<br />

pFormat = getTextStyle("p", this.sheet);<br />

if (pFormat == null)<br />

{<br />

pFormat = getDefaultTextFormat();<br />

pFormat.size = 12;<br />

}<br />

displayText();<br />

The onCSSFileLoaded() method creates a StyleSheet object and has it parse the input CSS data. The main text for the<br />

story is displayed in a MultiColumnTextField object, which can use a StyleSheet object directly. However, the headline<br />

fields use the HeadlineTextField class, which uses a TextFormat object for its formatting.<br />

Last updated 6/6/2012<br />

389

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

Saved successfully!

Ooh no, something went wrong!