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 Text Layout Framework<br />

from the insufferable glare, thrust in huge logs of oak, or stirred the imm<strong>en</strong>se brands with a<br />

long pole. Within the furnace were se<strong>en</strong> the curling and riotous flames, and the burning marble,<br />

almost molt<strong>en</strong> with the int<strong>en</strong>sity of heat; while without, the reflection of the fire quivered on<br />

the dark intricacy of the surrounding forest, and showed in the foreground a bright and ruddy<br />

little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of<br />

the lime-burner, and the half-fright<strong>en</strong>ed child, shrinking into the protection of his father's<br />

shadow. And wh<strong>en</strong> again the iron door was closed, th<strong>en</strong> reappeared the t<strong>en</strong>der light of the halffull<br />

moon, which vainly strove to trace out the indistinct shapes of the neighboring mountains;<br />

and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the<br />

rosy sunset, though thus far down into the valley the sunshine had vanished long and long<br />

ago.";<br />

public function TLFNewsLayout()<br />

{<br />

//wait for stage to exist<br />

addEv<strong>en</strong>tList<strong>en</strong>er(Ev<strong>en</strong>t.ADDED_TO_STAGE, onAddedToStage);<br />

}<br />

private function onAddedToStage(evtObj:Ev<strong>en</strong>t):void<br />

{<br />

removeEv<strong>en</strong>tList<strong>en</strong>er(Ev<strong>en</strong>t.ADDED_TO_STAGE, onAddedToStage);<br />

stage.scaleMode = StageScaleMode.NO_SCALE;<br />

stage.align = StageAlign.TOP_LEFT;<br />

// Headline text flow and flow composer<br />

hTextFlow = TextConverter.importToFlow(headlineMarkup,<br />

TextConverter.TEXT_LAYOUT_FORMAT);<br />

// initialize the headline container and controller objects<br />

headContainer = new Sprite();<br />

headlineController = new ContainerController(headContainer);<br />

headlineController.verticalScrollPolicy = ScrollPolicy.OFF;<br />

hContainerFormat = new TextLayoutFormat();<br />

hContainerFormat.paddingTop = 4;<br />

hContainerFormat.paddingRight = 4;<br />

hContainerFormat.paddingBottom = 4;<br />

hContainerFormat.paddingLeft = 4;<br />

headlineController.format = hContainerFormat;<br />

hTextFlow.flowComposer.addController(headlineController);<br />

addChild(headContainer);<br />

stage.addEv<strong>en</strong>tList<strong>en</strong>er(flash.ev<strong>en</strong>ts.Ev<strong>en</strong>t.RESIZE, resizeHandler);<br />

// Body text TextFlow and flow composer<br />

bTextFlow = TextConverter.importToFlow(bodyMarkup,<br />

TextConverter.TEXT_LAYOUT_FORMAT);<br />

// The body text container is below, and has three columns<br />

bodyTextContainer = new Sprite();<br />

bodyController = new ContainerController(bodyTextContainer);<br />

bodyTextContainerFormat = new TextLayoutFormat();<br />

bodyTextContainerFormat.columnCount = 3;<br />

bodyTextContainerFormat.columnGap = 30;<br />

bodyController.format = bodyTextContainerFormat;<br />

bTextFlow.flowComposer.addController(bodyController);<br />

addChild(bodyTextContainer);<br />

Last updated 6/6/2012<br />

430

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

Saved successfully!

Ooh no, something went wrong!