| 包 | flashx.textLayout.factory |
| 类 | public class TextFlowTextLineFactory |
| 继承 | TextFlowTextLineFactory TextLineFactoryBase Object |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
文本行是静态的,创建时位于单个矩形边框内,但是可以具有多个段落和格式以及内嵌图形。要直接通过字符串创建 TextLine 对象,可使用 StringTextLineFactory。
注意:使用内嵌图形时,InlineGraphicElement 对象的 source 属性必须是 DisplayObject 的实例或表示嵌入资源的 Class 对象。不能使用 URLRequest 对象。创建行时内嵌图形的宽度和高度用于合成流。
相关 API 元素
公共方法
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
创建 TextFlowTextLineFactory 对象。 | TextFlowTextLineFactory | ||
基于指定文本流创建 TextLine 对象。 | TextFlowTextLineFactory | ||
![]() |
布局内容位于的最小矩形。 | TextLineFactoryBase | |
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
构造函数详细信息
TextFlowTextLineFactory | () | 构造函数 |
public function TextFlowTextLineFactory()| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
创建 TextFlowTextLineFactory 对象。
方法详细信息
createTextLines | () | 方法 |
public function createTextLines(callback:Function, textFlow:flashx.textLayout.elements:TextFlow):void| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
基于指定文本流创建 TextLine 对象。
文本行合成时将位于指定给 compositionBounds 属性的边界范围内。创建每一行时,工厂会调用 callback 参数指定的函数。该函数接受 TextLine 对象作为参数,负责显示文本行。如果某行具有背景色,则该工厂还会使用包含一个背景色矩形的 Shape 对象调用该回调函数。
注意:factory 的滚动策略将控制生成的行数。
参数
callback:Function — 对生成的每一 TextLine 对象调用的函数。将使用表示任何背景色(如果存在)的 Shape 对象以及文本的 TextLine 对象调用该回调。
| |
textFlow:flashx.textLayout.elements:TextFlow — 创建文本行所使用的 TextFlow。
|
示例 如何使用本示例
TextFlowTextLineFactory_example.as
以下示例使用了 TextFlowTextLineFactory 创建一组文本行。工厂方法
createTextLines() 使用同一短语调用了两次。在两次调用之间会调整工厂属性和流格式,以生成“投影”效果。
package flashx.textLayout.factory.examples
{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.geom.Rectangle;
import flash.text.engine.TextLine;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.factory.TextFlowTextLineFactory;
import flashx.textLayout.formats.TextLayoutFormat;
public class TextFlowTextLineFactory_example extends Sprite
{
public function TextFlowTextLineFactory_example()
{
var factory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
factory.compositionBounds = new Rectangle( 100, 100, 200, 130 );
var flow:TextFlow = new TextFlow();
var format:TextLayoutFormat = new TextLayoutFormat();
format.fontFamily = "LilyUPC, Verdana, _sans";
format.fontSize = 32;
format.color = 0x000000;
format.textAlpha = .5;
var span:SpanElement = new SpanElement();
span.text = "The quick brown fox jumped over the lazy dog.";
span.format = format;
var para:ParagraphElement = new ParagraphElement();
para.addChild( span );
flow.addChild( para );
factory.createTextLines( useTextLines, flow );
factory.compositionBounds = new Rectangle( 99, 99, 200, 130 );
format.color = 0x990000;
format.textAlpha = 1;
span.format = format;
factory.createTextLines( useTextLines, flow );
graphics.beginFill(0x555555,.5);
graphics.drawRect( 99, 99, 201, 131 );
graphics.endFill();
}
private function useTextLines( lineOrShape:DisplayObject ):void
{
this.addChild( lineOrShape );
}
}
}
Tue Jun 12 2018, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性