| 包 | flash.text.engine |
| 类 | public final class SpaceJustifier |
| 继承 | SpaceJustifier TextJustifier Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
使用构造函数 new SpaceJustifier() 创建 SpaceJustifier 对象后才能设置其属性。将 SpaceJustifier 对象应用于 TextBlock 后设置该对象的属性不会使 TextBlock 无效。
另请参见
| 属性 | 定义方 | ||
|---|---|---|---|
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| letterSpacing : Boolean 指定对齐过程中是否使用字母间距。 | SpaceJustifier | ||
![]() | lineJustification : String 指定文本块中文本的行对齐方式。 | TextJustifier | |
![]() | locale : String [只读 (read-only)] 指定用于确定文本块中文本的对齐规则的区域设置。 | TextJustifier | |
![]() | prototype : Object [静态]
对类或函数对象的原型对象的引用。 | Object | |
| 方法 | 定义方 | ||
|---|---|---|---|
SpaceJustifier(locale:String = "en", lineJustification:String = "unjustified", letterSpacing:Boolean = false) 创建一个 SpaceJustifier 对象。 | SpaceJustifier | ||
构造 SpaceJustifier 的克隆副本。 | SpaceJustifier | ||
![]() | [静态] 构造对应于指定的区域设置的默认 TextJustifier 子类。 | TextJustifier | |
![]() |
指示对象是否已经定义了指定的属性。 | Object | |
![]() |
指示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
指示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
| letterSpacing | 属性 |
letterSpacing:Boolean [读写] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
指定对齐过程中是否使用字母间距。
public function get letterSpacing():Boolean public function set letterSpacing(value:Boolean):void| SpaceJustifier | () | 构造函数 |
public function SpaceJustifier(locale:String = "en", lineJustification:String = "unjustified", letterSpacing:Boolean = false)| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
创建一个 SpaceJustifier 对象。LineJustification 类包含用于指定可应用的行对齐类型的常量。
参数locale:String (default = "en") —
用于确定对齐规则的区域设置。默认值为 "en"。
| |
lineJustification:String (default = "unjustified") —
段落的行对齐类型。将 LineJustification 常量用于此属性。默认值为 LineJustification.UNJUSTIFIED。
| |
letterSpacing:Boolean (default = false) —
指定对齐过程中是否使用字母间距。默认值为 false。
|
ArgumentError —
指定的 locale 为 null 或太短,不能表示有效的区域设置。
| |
ArgumentError —
指定的 lineJustification 不是 LineJustification 的成员。
|
另请参见
| clone | () | 方法 |
override public function clone():TextJustifier| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
构造 SpaceJustifier 的克隆副本。
返回TextJustifier —
SpaceJustifier 对象的副本。
|
package {
import flash.display.Sprite;
import flash.text.engine.TextBlock;
import flash.text.engine.TextElement;
import flash.text.engine.TextLine;
import flash.text.engine.ElementFormat;
import flash.text.engine.SpaceJustifier;
import flash.text.engine.LineJustification;
public class SpaceJustifierExample extends Sprite {
public function SpaceJustifierExample():void {
var str:String = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " +
"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
"aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit " +
"in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur " +
"sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " +
"mollit anim id est laborum.";
var format:ElementFormat = new ElementFormat(null, 12, 0xCC0000);
var textElement:TextElement = new TextElement(str, format);
var spaceJustifier:SpaceJustifier = new SpaceJustifier("en", LineJustification.ALL_BUT_LAST);
spaceJustifier.letterSpacing = true;
var textBlock:TextBlock = new TextBlock();
textBlock.content = textElement;
textBlock.textJustifier = spaceJustifier;
createLines(textBlock);
}
private function createLines(textBlock:TextBlock):void {
var yPos = 20;
var textLine:TextLine = textBlock.createTextLine (null, 150);
while (textLine)
{
addChild(textLine);
textLine.x = 15;
yPos += textLine.textHeight+2;
textLine.y = yPos;
textLine = textBlock.createTextLine(textLine, 150);
}
}
}
}