| 套件 | flashx.textLayout.elements |
| 類別 | public final class ParagraphElement |
| 繼承 | ParagraphElement ParagraphFormattedElement FlowGroupElement FlowElement Object |
| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
預設 MXML 屬性mxmlChildren
更多範例
相關 API 元素
公用方法
| 方法 | 定義自 | ||
|---|---|---|---|
建構函式 - 代表文字流排中的段落。 | ParagraphElement | ||
![]() |
附加子系 FlowElement 物件。 | FlowGroupElement | |
![]() |
在指定的索引位置新增子系 FlowElement 物件。 | FlowGroupElement | |
![]() | 清除此 FlowElement 物件中由 styleProp 參數所指定的樣式。 | FlowElement | |
![]() |
製作此 FlowElement 物件 (包含任何子系) 的深層複本,這會複製兩個指定字元位置之間的內容,並傳回複本做為 FlowElement 物件。 | FlowElement | |
![]() | 將這一個的 userStyles 與 otherElement 的 userStyles 進行比較。 | FlowElement | |
![]() |
指定相對文字位置,尋找第一個內含相對位置的子系 FlowElement 的索引。 | FlowGroupElement | |
![]() |
指定相對文字位置,尋找內含位置的分葉元素。 | FlowGroupElement | |
從提供的位置往前掃描,以尋找下一個 Atom 文字中的位置,並傳回索引。 | ParagraphElement | ||
傳回文字中下一個單字邊界的索引。 | ParagraphElement | ||
從提供的位置往回掃描,以尋找文字中上一個 Atom 的位置,並傳回索引。 | ParagraphElement | ||
傳回文字中上一個單字邊界的索引。 | ParagraphElement | ||
![]() |
傳回文字流排中的元素開始位置做為絕對索引。 | FlowElement | |
![]() |
傳回指定位置的字元 (與此 FlowElement 物件相對的位置)。 | FlowElement | |
![]() | 傳回指定位置的字元碼 (與此 FlowElement 相對的位置)。 | FlowElement | |
![]() |
傳回指定索引位置的 FlowElement 子系。 | FlowGroupElement | |
![]() |
搜尋子系以找出指定的 FlowElement 物件,並傳回其索引位置。 | FlowGroupElement | |
![]() |
傳回此元素的開頭 (與祖系元素相對的位置)。 | FlowElement | |
![]() |
傳回此群組的第一個 FlowLeafElement 子系。 | FlowGroupElement | |
![]() |
傳回此群組的最後一個 FlowLeafElement 子系。 | FlowGroupElement | |
傳回在此段落後面的段落;如果沒有其他段落,則會傳回 null。 | ParagraphElement | ||
![]() | 傳回文字流排階層中的下一個 FlowElement 同級項目。 | FlowElement | |
![]() |
傳回與此元素相關的 ParagraphElement 物件。 | FlowElement | |
傳回此段落前面的段落;如果此段落是 TextFlow 中的第一段,則為 null。 | ParagraphElement | ||
![]() | 傳回文字流排階層中的上一個 FlowElement 同級項目。 | FlowElement | |
![]() | 傳回 styleProp 參數所指定的樣式值,此參數會指定樣式名稱,而且可以包含任何使用者樣式名稱。 | FlowElement | |
![]() | [覆寫] | FlowGroupElement | |
![]() |
往上瀏覽文字流排階層,以傳回元素的根 TextFlow 物件。 | FlowElement | |
![]() |
指出物件是否有已定義的指定屬性。 | Object | |
![]() | 實作物件已經建立而且在 MXML 標籤上指定的所有組件屬性已經初始化後,為 MXML 物件進行呼叫。 | FlowElement | |
![]() |
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | |
![]() |
指出指定的屬性是否存在,以及是否可列舉。 | Object | |
![]() |
從群組中移除指定的子系 FlowElement 物件。 | FlowGroupElement | |
![]() |
移除指定索引位置的子系 FlowElement 物件。 | FlowGroupElement | |
![]() |
將群組中的子元素取代為指定的新元素。 | FlowGroupElement | |
![]() |
為迴圈作業設定動態屬性的可用性。 | Object | |
![]() | 將 styleProp 參數所指定的樣式設為 newValue 參數所指定的值。 | FlowElement | |
![]() |
製作此 FlowElement 物件的複本,這會複製兩個指定字元位置之間的內容。 | FlowElement | |
![]() |
在 childIndex 參數指定的位置分割此物件。 | FlowGroupElement | |
![]() |
在 relativePosition 參數指定的位置分割此 FlowElement 物件,而此參數是此元素在文字中的相對位置。 | FlowElement | |
![]() |
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | |
![]() |
會傳回指定之物件的字串形式。 | Object | |
![]() |
會傳回指定之物件的基本值。 | Object | |
建構函式詳細資料
ParagraphElement | () | 建構函式 |
public function ParagraphElement()| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
建構函式 - 代表文字流排中的段落。
方法詳細資訊
findNextAtomBoundary | () | 方法 |
public function findNextAtomBoundary(relativePosition:int):int| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
從提供的位置往前掃描,以尋找下一個 Atom 文字中的位置,並傳回索引。Atom 一詞同時可做為圖形元素與字元 (包括結合的字元群組) 來解釋,亦即組成文字行的實體。
參數
relativePosition:int — 文字的開始位置 (從 0 開始算起)
|
int — 下列 Atom 文字中的索引
|
相關 API 元素
範例 ( 如何使用本範例 )
此範例會在段落中以指定的偏移量尋找下一個 Atom 邊界。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_findNextAtomBoundary extends Sprite
{
public function ParagraphElement_findNextAtomBoundary()
{
// create the TextFlow, ParagraphElement and SpanElement objects to hold paragraph
var textFlow:TextFlow = new TextFlow();
var paragraph:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
// assign text to the span; add span to paragraph and paragraph to TextFlow
span.text = "Hello brave, new world!";
paragraph.addChild(span);
textFlow.addChild(paragraph);
// assign a controller to the stage and update it to compose and display text
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// find the next atom boundaries from offsets 5 and 10
var atomBoundary:int = paragraph.findNextAtomBoundary(4);
trace(atomBoundary); // 5
atomBoundary = paragraph.findNextAtomBoundary(10);
trace(atomBoundary); // 11
}
}
}
findNextWordBoundary | () | 方法 |
public function findNextWordBoundary(relativePosition:int):int| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
傳回文字中下一個單字邊界的索引。
從提供的位置往前掃描,以尋找的文字中下一個單字開頭或結尾的位置。
參數
relativePosition:int — 文字的開始位置 (從 0 開始算起)
|
int — 下一個單字邊界文字中的索引
|
範例 ( 如何使用本範例 )
此範例會在段落中以指定的偏移量尋找下一個單字邊界。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_findNextWordBoundary extends Sprite
{
public function ParagraphElement_findNextWordBoundary()
{
// create the TextFlow, ParagraphElement and SpanElement objects to hold paragraph
var textFlow:TextFlow = new TextFlow();
var paragraph:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
// assign text to the span; add span to paragraph and paragraph to TextFlow
span.text = "Hello brave, new world!";
paragraph.addChild(span);
textFlow.addChild(paragraph);
// assign a controller to the stage and update it to compose and display text
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// find the next word boundary from offsets 0 and 12
var wordBoundary:int = paragraph.findNextWordBoundary(0);
trace(wordBoundary); // 5
wordBoundary = paragraph.findNextWordBoundary(12);
trace(wordBoundary); // 13
}
}
}
findPreviousAtomBoundary | () | 方法 |
public function findPreviousAtomBoundary(relativePosition:int):int| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
從提供的位置往回掃描,以尋找文字中上一個 Atom 的位置,並傳回索引。Atom 一詞同時可做為圖形元素與字元 (包括結合的字元群組) 來解釋,亦即組成文字行的實體。
參數
relativePosition:int — 文字的開始位置 (從 0 開始算起)
|
int — 上一個叢集文字中的索引
|
相關 API 元素
範例 ( 如何使用本範例 )
此範例會在段落中以指定的偏移量尋找上一個 Atom 邊界。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_findPreviousAtomBoundary extends Sprite
{
public function ParagraphElement_findPreviousAtomBoundary()
{
// create the TextFlow, ParagraphElement and SpanElement objects to hold paragraph
var textFlow:TextFlow = new TextFlow();
var paragraph:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
// assign text to the span; add span to paragraph and paragraph to TextFlow
span.text = "Hello brave, new world!";
paragraph.addChild(span);
textFlow.addChild(paragraph);
// assign a controller to the stage and update it to compose and display text
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// find the previous atom boundaries from offsets 6 and 13
var atomBoundary:int = paragraph.findPreviousAtomBoundary(6);
trace(atomBoundary); // 5
atomBoundary = paragraph.findPreviousAtomBoundary(13);
trace(atomBoundary); // 12
}
}
}
findPreviousWordBoundary | () | 方法 |
public function findPreviousWordBoundary(relativePosition:int):int| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
傳回文字中上一個單字邊界的索引。
從提供的位置往回掃描,以尋找的文字中上一個單字開頭或結尾的位置。
參數
relativePosition:int — 文字的開始位置 (從 0 開始算起)
|
int — 上一個單字邊界文字中的索引
|
範例 ( 如何使用本範例 )
此範例會在段落中以指定的偏移量尋找上一個單字邊界。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_findPreviousWordBoundary extends Sprite
{
public function ParagraphElement_findPreviousWordBoundary()
{
// create the TextFlow, ParagraphElement and SpanElement objects to hold paragraph
var textFlow:TextFlow = new TextFlow();
var paragraph:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
// assign text to the span; add span to paragraph and paragraph to TextFlow
span.text = "Hello brave, new world!";
paragraph.addChild(span);
textFlow.addChild(paragraph);
// assign a controller to the stage and update it to compose and display text
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// find the previous word boundary from offsets 0 and 12
var wordBoundary:int = paragraph.findPreviousWordBoundary(22);
trace(wordBoundary); // 17
wordBoundary = paragraph.findPreviousWordBoundary(11);
trace(wordBoundary); // 6
}
}
}
getNextParagraph | () | 方法 |
public function getNextParagraph():ParagraphElement| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
傳回在此段落後面的段落;如果沒有其他段落,則會傳回 null。
傳回值ParagraphElement — 下一個段落;如果沒有其他段落,則會傳回 null。
|
相關 API 元素
範例 ( 如何使用本範例 )
此範例會從 xml 標記匯入三段文字、使用 getChildAtIndex(0) 存取第一段,而使用 getNextParagraph() 存取第二段。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_getNextParagraph extends Sprite
{
public function ParagraphElement_getNextParagraph()
{
// create TextFlow object
var textFlow:TextFlow = new TextFlow();
// create content for TextFlow using XML markup
var simpleText:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<flow:TextFlow xmlns:flow=\"http://ns.adobe.com/textLayout/2008\">"+
"<flow:p>"+
"<flow:span>This is the first paragraph.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>This is the second paragraph.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>This is the third paragraph.</flow:span>"+
"</flow:p>"+
"</flow:TextFlow>";
// import the xml markup into a TextFlow object and display it on the stage
textFlow = TextConverter.importToFlow(simpleText, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// get first paragraph
var p:ParagraphElement = textFlow.getChildAt(0) as ParagraphElement;
// get next paragraph and display its content
var nextParagraph:ParagraphElement = p.getNextParagraph();
trace("nextParagraph.text is: " + nextParagraph.getText());
}
}
}
getPreviousParagraph | () | 方法 |
public function getPreviousParagraph():ParagraphElement| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
傳回此段落前面的段落;如果此段落是 TextFlow 中的第一段,則為 null。
傳回值ParagraphElement |
相關 API 元素
範例 ( 如何使用本範例 )
此範例會從 xml 標記匯入三段文字、使用 getChildAtIndex(1) 存取第二段,而使用 getPreviousParagraph() 存取第一段。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
public class ParagraphElement_getPreviousParagraph extends Sprite
{
public function ParagraphElement_getPreviousParagraph()
{
// create TextFlow object
var textFlow:TextFlow = new TextFlow();
// create content for TextFlow using XML markup
var simpleText:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<flow:TextFlow xmlns:flow=\"http://ns.adobe.com/textLayout/2008\">"+
"<flow:p>"+
"<flow:span>This is the first paragraph.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>This is the second paragraph.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>This is the third paragraph.</flow:span>"+
"</flow:p>"+
"</flow:TextFlow>";
// import the xml markup into a TextFlow object and display it on the stage
textFlow = TextConverter.importToFlow(simpleText, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
// get second paragraph (first = 0)
var p:ParagraphElement = textFlow.getChildAt(1) as ParagraphElement;
// get previous paragraph and display its content
var prevParagraph:ParagraphElement = p.getPreviousParagraph();
trace("prevParagraph.text is: " + prevParagraph.getText());
}
}
}
範例 如何使用本範例
ParagraphElementExample.as
此範例會建立並格式化三段文字。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flash.text.engine.FontPosture;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.formats.TextLayoutFormat;
public class ParagraphElementExample extends Sprite {
// create the TextFlow object
private var textFlow:TextFlow = new TextFlow();
// Create Strings of text for the paragraphs
private var para1String:String = "In the first paragraph of a "
private var para1String2:String = "cheap"
private var para1String3:String ="Western novel, a cowboy meets a saloon girl.";
private var para2String:String = "In the middle of the cheap novel a really bad guy, "+
"who is having a relationship with the saloon girl, sees the cowboy help "+
"her onto her horse as she smiles at him warmly."
private var para3String:String = "In the last paragraph of the cheap novel, the cowboy kills "+
"the really bad guy in a shootout in the middle of main street and "+
"then rides into the sunset with the saloon girl on the back of his horse.";
public function ParagraphElementExample()
{
// create a TextLayoutFormat object to use in formatting the paragraphs
var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
var paragraph1:ParagraphElement = new ParagraphElement();
// create the ParagraphElement objects
var paragraph2:ParagraphElement = new ParagraphElement();
var paragraph3:ParagraphElement = new ParagraphElement();
// create the SpanElement objects to hold the content of the paragraphs
var p1Span1:SpanElement = new SpanElement();
var p1Span2:SpanElement = new SpanElement();
var p1Span3:SpanElement = new SpanElement();
var p2Span:SpanElement = new SpanElement();
var p3Span:SpanElement = new SpanElement();
// assign the strings of text for the 1st paragraph to spans
p1Span1.text = para1String;
p1Span2.text = para1String2;
p1Span2.fontStyle = FontPosture.ITALIC; // italicize 'cheap'
p1Span3.text = para1String3;
// add spans to first paragraph
paragraph1.addChild(p1Span1);
paragraph1.addChild(p1Span2);
paragraph1.addChild(p1Span3);
// assign the string of text for the 2nd paragraph to a span
// and add the span to the second paragraph
p2Span.text = para2String;
paragraph2.addChild(p2Span);
// assign the string of text for the 3rd paragraph to a span
// and add the span to the third paragraph
p3Span.text = para3String;
paragraph3.addChild(p3Span);
// add the paragraphs to the TextFlow
textFlow.addChild(paragraph1);
textFlow.addChild(paragraph2);
textFlow.addChild(paragraph3);
// set the text formatting properties
textLayoutFormat.fontSize = 14;
textLayoutFormat.textIndent = 15;
textLayoutFormat.paragraphSpaceAfter = 15;
textLayoutFormat.paddingTop = 4;
textLayoutFormat.paddingLeft = 4;
// assign the format object to the TextFlow
textFlow.hostFormat = textLayoutFormat;
// assign a controller to the stage and update it to compose and
// display the text
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
}
}
}
ParagraphElementExample2.as
此範例會將 xml 標記匯入至 TextFlow 物件。此 xml 標記定義三段與上個範例相同的文字及格式。
package flashx.textLayout.elements.examples
{
import flash.display.Sprite;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.container.ContainerController;
public class ParagraphElementExample2 extends Sprite {
// create the TextFlow object
private var textFlow:TextFlow = new TextFlow();
// xml markup that defines the attributes and contents of a text flow
private var simpleText:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<flow:TextFlow xmlns:flow=\"http://ns.adobe.com/textLayout/2008\" verticalScrollPolicy=\"auto\" horizontalScrollPolicy=\"auto\" editingMode=\"readWrite\" fontSize=\"14\" textIndent=\"15\" marginBottom=\"15\" paddingTop=\"4\" paddingLeft=\"4\">"+
"<flow:p>"+
"<flow:span>In the first paragraph of a </flow:span>"+
"<flow:span fontStyle=\"italic\">cheap</flow:span>"+
"<flow:span> Western novel, a cowboy meets a saloon girl.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>In the middle of the cheap novel a really bad guy, </flow:span>"+
"<flow:span>who is having a relationship with the saloon girl, sees the cowboy help </flow:span>"+
"<flow:span>her onto her horse as she smiles at him warmly.</flow:span>"+
"</flow:p>"+
"<flow:p>"+
"<flow:span>In the last paragraph of the cheap novel, the cowboy kills the really </flow:span>"+
"<flow:span> bad guy in a shootout in the middle of main street and then rides into the sunset with </flow:span>"+
"<flow:span>the saloon girl on the back of his horse.</flow:span>" +
"</flow:p>"+
"</flow:TextFlow>";
public function ParagraphElementExample2()
{
// import the xml markup into a TextFlow object and display it on the stage
textFlow = TextConverter.importToFlow(simpleText, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer.addController(new ContainerController(this, 200, 400));
textFlow.flowComposer.updateAllControllers();
}
}
}
Tue Jun 12 2018, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性