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 />

The onCSSFileLoaded() method calls the getTextStyle() method twice to convert a CSS style declaration into a<br />

TextFormat object for use with each of the two HeadlineTextField objects.<br />

public function getTextStyle(styleName:String, ss:StyleSheet):TextFormat<br />

{<br />

var format:TextFormat = null;<br />

}<br />

var style:Object = ss.getStyle(styleName);<br />

if (style != null)<br />

{<br />

var colorStr:String = style.color;<br />

if (colorStr != null && colorStr.indexOf("#") == 0)<br />

{<br />

style.color = colorStr.substr(1);<br />

}<br />

format = new TextFormat(style.fontFamily,<br />

style.fontSize,<br />

style.color,<br />

(style.fontWeight == "bold"),<br />

(style.fontStyle == "italic"),<br />

(style.textDecoration == "underline"),<br />

style.url,<br />

style.target,<br />

style.textAlign,<br />

style.marginLeft,<br />

style.marginRight,<br />

style.ind<strong>en</strong>t,<br />

style.leading);<br />

if (style.hasOwnProperty("letterSpacing"))<br />

{<br />

format.letterSpacing = style.letterSpacing;<br />

}<br />

}<br />

return format;<br />

The property names and the meaning of the property values differ betwe<strong>en</strong> CSS style declarations and TextFormat<br />

objects. The getTextStyle() method translates CSS property values into the values expected by the TextFormat<br />

object.<br />

Arranging story elem<strong>en</strong>ts on the page<br />

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

The StoryLayout class formats and lays out the headline, subtitle, and main text fields into a newspaper-style<br />

arrangem<strong>en</strong>t. The displayText() method initially creates and places the various fields.<br />

Last updated 6/6/2012<br />

390

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

Saved successfully!

Ooh no, something went wrong!