| 套件 | flashx.textLayout.formats |
| 類別 | public final class TextAlign |
| 繼承 | TextAlign Object |
| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
textAlign 及 textAlignLast 屬性的值。這些值描述段落中字行相對於容器的對齊。
相關 API 元素
公用常數
| 常數 | 定義自 | ||
|---|---|---|---|
| CENTER : String = "center" [靜態] 指定容器內的置中對齊。 | TextAlign | ||
| END : String = "end" [靜態] 指定結尾邊緣對齊 - 文字的對齊方向與寫入方向相反。 | TextAlign | ||
| JUSTIFY : String = "justify" [靜態] 指定文字在字行中為左右對齊,以填滿容器空間。 | TextAlign | ||
| LEFT : String = "left" [靜態] 指定對齊左邊緣。 | TextAlign | ||
| RIGHT : String = "right" [靜態] 指定對齊右邊緣。 | TextAlign | ||
| START : String = "start" [靜態] 指定開頭邊緣對齊 - 文字對齊方向與寫入方向一致。 | TextAlign | ||
常數詳細資訊
CENTER | 常數 |
public static const CENTER:String = "center"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定容器內的置中對齊。
END | 常數 |
public static const END:String = "end"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定結尾邊緣對齊 - 文字的對齊方向與寫入方向相反。等同於指定由左向右文字的靠右對齊,或由右向左文字的靠左對齊。
JUSTIFY | 常數 |
public static const JUSTIFY:String = "justify"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定文字在字行中為左右對齊,以填滿容器空間。
LEFT | 常數 |
public static const LEFT:String = "left"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定對齊左邊緣。
RIGHT | 常數 |
public static const RIGHT:String = "right"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定對齊右邊緣。
START | 常數 |
public static const START:String = "start"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
指定開頭邊緣對齊 - 文字對齊方向與寫入方向一致。等同於設定由左向右文字的靠左對齊,或由右向左文字的靠右對齊。
範例 如何使用本範例
TextAlignExample.as
這個範例會使用 CENTER、JUSTIFY 和 RIGHT 對齊方式,對齊 "Hello World" 的三個段落。
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();
}
}
}
Tue Jun 12 2018, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性