| 套件 | flashx.textLayout.factory |
| 類別 | public class StringTextLineFactory |
| 繼承 | StringTextLineFactory TextLineFactoryBase Object |
| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
文字行是靜態的,使用單一格式及單一段落建立。建立指定邊界矩形中可容納的文字行。
由於在許多重複叫用中反覆使用單一 TextFlow、ParagraphElement、SpanElement 及 ContainerController 物件,因此 StringTextLineFactory 提供一個建立 TextLines 的有效方式。您可以建立單一出廠,並重複使用。您也可以重複使用每次呼叫時都相同的元件;例如,您可以重複使用各種格式及邊界。
注意:若要建立使用多重格式或段落的靜態字行,或是包含內嵌圖形的靜態字行,請使用 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()。在呼叫之間調整出廠屬性以建立「drop shadow」效果。
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, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性