Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Defines values for setting the
textAlign
and
textAlignLast
properties
of the TextLayoutFormat class. The values describe the alignment of lines in the paragraph relative to the
container.
View the examples
public static const CENTER:String = "center"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies center alignment within the container.
public static const END:String = "end"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies end edge alignment - text is aligned opposite from the writing order. Equivalent to
specifying right in left-to-right text, or left in right-to-left text.
public static const JUSTIFY:String = "justify"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies that text is justified within the lines so they fill the container space.
public static const LEFT:String = "left"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies left edge alignment.
public static const RIGHT:String = "right"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies right edge alignment.
public static const START:String = "start"
Language Version: | ActionScript 3.0 |
Runtime Versions: | Flash Player 10, AIR 1.5 |
Specifies start edge alignment - text is aligned to match the writing order. Equivalent to setting
left in left-to-right text, or right in right-to-left text.
This example aligns three paragraphs of "Hello World" using
CENTER, JUSTIFY, and RIGHT alignment.
package flashx.textLayout.formats.examples {
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextAlign;
import flashx.textLayout.formats.TextJustify;
public class TextAlignExample extends Sprite
{
public function TextAlignExample()
{
var textFlow:TextFlow = new TextFlow();
//create paragraphs and corresponding spans
var pCenter:ParagraphElement = new ParagraphElement();
var pJustify:ParagraphElement = new ParagraphElement();
var pRight:ParagraphElement = new ParagraphElement();
var spanCenter:SpanElement = new SpanElement();
var spanJustify:SpanElement = new SpanElement();
var spanRight:SpanElement = new SpanElement();
// add text to the spans
spanCenter.text = "Hello, World\n";
spanJustify.text = "Hello, World\n";
spanRight.text = "Hello, World";
// add spans to paragraphs and specify alignment
pCenter.addChild(spanCenter);
pCenter.textAlign = TextAlign.CENTER;
pJustify.addChild(spanJustify);
pJustify.textAlign = TextAlign.JUSTIFY;
pJustify.textJustify = TextJustify.DISTRIBUTE;
pRight.addChild(spanRight);
pRight.textAlign = TextAlign.RIGHT;
// add paragraphs to TextFlow
textFlow.addChild(pCenter);
textFlow.addChild(pJustify);
textFlow.addChild(pRight);
// update controller to display
textFlow.flowComposer.addController(new ContainerController(this,80,800));
textFlow.flowComposer.updateAllControllers();
}
}
}