flash.text.engine
public final class SpaceJustifier
继承SpaceJustifier Inheritance TextJustifier Inheritance Object

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

SpaceJustifier 类表示控制文本块中文本行的对齐选项的属性。

使用构造函数 new SpaceJustifier() 创建 SpaceJustifier 对象后才能设置其属性。将 SpaceJustifier 对象应用于 TextBlock 后设置该对象的属性不会使 TextBlock 无效。

查看示例

另请参见

LineJustification
TextBlock.textJustifier
TextJustifier


公共属性
 属性定义方
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
  letterSpacing : Boolean
指定对齐过程中是否使用字母间距。
SpaceJustifier
 InheritedlineJustification : String
指定文本块中文本的行对齐方式。
TextJustifier
 Inheritedlocale : String
[只读 (read-only)] 指定用于确定文本块中文本的对齐规则的区域设置。
TextJustifier
 Inheritedprototype : Object
[静态] 对类或函数对象的原型对象的引用。
Object
公共方法
 方法定义方
  
SpaceJustifier(locale:String = "en", lineJustification:String = "unjustified", letterSpacing:Boolean = false)
创建一个 SpaceJustifier 对象。
SpaceJustifier
  
构造 SpaceJustifier 的克隆副本。
SpaceJustifier
 Inherited
[静态] 构造对应于指定的区域设置的默认 TextJustifier 子类。
TextJustifier
 Inherited
指示对象是否已经定义了指定的属性。
Object
 Inherited
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
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 — 指定的 localenull 或太短,不能表示有效的区域设置。
 
ArgumentError — 指定的 lineJustification 不是 LineJustification 的成员。

另请参见

方法详细信息
clone()方法
override public function clone():TextJustifier

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

构造 SpaceJustifier 的克隆副本。

返回
TextJustifierSpaceJustifier 对象的副本。
示例 如何使用示例
SpaceJustifierExample.as

以下示例将使用字母间距,并将文本块中最后一行以外的所有行对齐。
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);
            }        
        }
    }
}