| 套件 | 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()。在呼叫之間調整出廠屬性及排列格式以建立「drop shadow」效果。
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, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性