15.10.2012 Views

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

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.

ACTIONSCRIPT 3.0 ENTWICKLERHANDBUCH<br />

Verwenden der Flash Text Engine<br />

package {<br />

}<br />

import flash.text.engine.*;<br />

import flash.display.Sprite;<br />

public class TabStopExample extends Sprite<br />

{<br />

public function TabStopExample()<br />

{<br />

var format:ElementFormat = new ElementFormat();<br />

format.fontDescription = new FontDescription("Arial");<br />

format.fontSize = 16;<br />

}<br />

}<br />

var tabStops:Vector. = new Vector.();<br />

tabStops.push(<br />

new TabStop(TabAlignment.START, 20),<br />

new TabStop(TabAlignment.CENTER, 140),<br />

new TabStop(TabAlignment.DECIMAL, 260, "."),<br />

new TabStop(TabAlignment.END, 380));<br />

var textBlock:TextBlock = new TextBlock();<br />

textBlock.content = new TextElement(<br />

"\tt1\tt2\tt3\tt4\n" +<br />

"\tThis line aligns on 1st tab\n" +<br />

"\t\t\t\tThis is the end\n" +<br />

"\tThe following fragment centers on the 2nd tab:\t\t\n" +<br />

"\t\tit's on me\t\t\n" +<br />

"\tThe following amounts align on the decimal point:\n" +<br />

"\t\t\t45.00\t\n" +<br />

"\t\t\t75,320.00\t\n" +<br />

"\t\t\t6,950.00\t\n" +<br />

"\t\t\t7.01\t\n", format);<br />

textBlock.tabStops = tabStops;<br />

var yPosition:Number = 60;<br />

var previousTextLine:TextLine = null;<br />

var textLine:TextLine;<br />

var i:int;<br />

for (i = 0; i < 10; i++) {<br />

textLine = textBlock.createTextLine(previousTextLine, 1000, 0);<br />

textLine.x = 20;<br />

textLine.y = yPosition;<br />

addChild(textLine);<br />

yPosition += 25;<br />

previousTextLine = textLine;<br />

}<br />

Letzte Aktualisierung 27.6.2012<br />

442

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

Saved successfully!

Ooh no, something went wrong!