| 包 | flashx.textLayout.factory |
| 类 | public class StringTextLineFactory |
| 继承 | StringTextLineFactory TextLineFactoryBase Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
文本行是静态的,使用单个格式和一个段落创建。这些创建的行位于指定的边界矩形范围内。
StringTextLineFactory 提供一种创建 TextLine 的高效方法,这是因为它在多个重复的调用中重用单个 TextFlow、ParagraphElement、SpanElement 和 ContainerController 对象。您可以创建单个工厂,然后多次重用它。也可以重用每次调用该工厂时相同的所有部分,例如,您可以重用各种格式和范围。
注意:要创建使用多个格式或包含多个段落的静态行,或包含内嵌图形的静态行,可使用 TextFlowTextLineFactory 和 TextFlow 对象。
注意:在截断文本时,StringTextLineFactory 会忽略 truncationOptions 中设置的 truncationIndicatorFormat 属性。
相关 API 元素
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
![]() | compositionBounds : Rectangle
创建文本行时所在的矩形。 | TextLineFactoryBase | |
| configuration : IConfiguration [只读]
内部 TextFlow 对象使用的配置。 | StringTextLineFactory | ||
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
| defaultConfiguration : IConfiguration [静态] [只读]
在未指定任何配置的情况下由该工厂使用的默认配置。 | StringTextLineFactory | ||
![]() | horizontalScrollPolicy : String
指定合成边界范围不够大时如何创建行。 | TextLineFactoryBase | |
![]() | isTruncated : Boolean [只读]
指示最后创建行时是否截断文本。 | TextLineFactoryBase | |
| paragraphFormat : flashx.textLayout.formats:ITextLayoutFormat
段落格式。 | StringTextLineFactory | ||
| spanFormat : flashx.textLayout.formats:ITextLayoutFormat
字符格式。 | StringTextLineFactory | ||
![]() | swfContext : ISWFContext
用于根据需要进行 FTE 调用的 ISWFContext 实例。 | TextLineFactoryBase | |
| text : String
要转换为 TextLine 对象的文本。 | StringTextLineFactory | ||
| textFlowFormat : flashx.textLayout.formats:ITextLayoutFormat
文本流格式。 | StringTextLineFactory | ||
![]() | truncationOptions : flashx.textLayout.factory:TruncationOptions
指定在文本在合成边界范围内不适合时用于截断文本的选项。 | TextLineFactoryBase | |
![]() | verticalScrollPolicy : String
指定合成边界范围不够大时如何创建行。 | TextLineFactoryBase | |
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
StringTextLineFactory(configuration:IConfiguration = null)
创建 StringTextLineFactory 对象。 | StringTextLineFactory | ||
使用当前指定给该工厂对象的文本创建 TextLine 对象。 | StringTextLineFactory | ||
![]() |
布局内容位于的最小矩形。 | TextLineFactoryBase | |
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
configuration | 属性 |
configuration:IConfiguration [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
内部 TextFlow 对象使用的配置。
实现
public function get configuration():IConfigurationdefaultConfiguration | 属性 |
defaultConfiguration:IConfiguration [只读] | 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
在未指定任何配置的情况下由该工厂使用的默认配置。
实现
public static function get defaultConfiguration():IConfigurationparagraphFormat | 属性 |
paragraphFormat:flashx.textLayout.formats:ITextLayoutFormat| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
段落格式。
实现
public function get paragraphFormat():flashx.textLayout.formats:ITextLayoutFormat public function set paragraphFormat(value:flashx.textLayout.formats:ITextLayoutFormat):voidspanFormat | 属性 |
spanFormat:flashx.textLayout.formats:ITextLayoutFormat| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
字符格式。
实现
public function get spanFormat():flashx.textLayout.formats:ITextLayoutFormat public function set spanFormat(value:flashx.textLayout.formats:ITextLayoutFormat):voidtext | 属性 |
textFlowFormat | 属性 |
textFlowFormat:flashx.textLayout.formats:ITextLayoutFormat| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
文本流格式。
实现
public function get textFlowFormat():flashx.textLayout.formats:ITextLayoutFormat public function set textFlowFormat(value:flashx.textLayout.formats:ITextLayoutFormat):voidStringTextLineFactory | () | 构造函数 |
public function StringTextLineFactory(configuration:IConfiguration = null)| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
创建 StringTextLineFactory 对象。
参数configuration:IConfiguration (default = null) — 配置对象,用于设置用来合成由该工厂生成的文本行的内部 TextFlow 对象的属性。
|
createTextLines | () | 方法 |
public function createTextLines(callback:Function):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
使用当前指定给该工厂对象的文本创建 TextLine 对象。
文本行使用当前指定的文本和格式创建,合成时位于指定给 compositionBounds 属性的边界范围内。创建每一行时,工厂会调用 callback 参数指定的函数。该函数接受 TextLine 对象作为参数,负责显示文本行。
要创建一组不同的文本行,可更改所需的任何属性,并再次调用 createTextLines()。
注意:factory 的滚动策略将控制生成的行数。
参数
callback:Function — 为创建的每一 TextLine 对象调用的回调函数。
|
createTextLines() 使用同一短语调用了两次。在两次调用之间会调整工厂属性,以生成“投影”效果。
package flashx.textLayout.factory.examples {
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flashx.textLayout.factory.StringTextLineFactory;
import flashx.textLayout.formats.TextLayoutFormat;
public class StringTextLineFactory_example extends Sprite
{
public function StringTextLineFactory_example()
{
var factory:StringTextLineFactory = new StringTextLineFactory();
factory.compositionBounds = new Rectangle( 100, 100, 200, 130 );
var format:TextLayoutFormat = new TextLayoutFormat();
format.fontFamily = "LilyUPC, Verdana, _sans";
format.fontSize = 32;
format.color = 0x000000;
format.textAlpha = .5;
factory.spanFormat = format;
factory.text = "The quick brown fox jumped over the lazy dog.";
factory.createTextLines( useTextLines );
factory.compositionBounds = new Rectangle( 99, 99, 200, 130 );
format.color = 0x990000;
format.textAlpha = 1;
factory.spanFormat = format;
factory.createTextLines( useTextLines );
graphics.beginFill(0x555555,.5);
graphics.drawRect( 99, 99, 201, 131 );
graphics.endFill();
}
private function useTextLines( line:DisplayObject ):void
{
var displayObject:DisplayObject = this.addChild( line );
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性