| 套件 | flashx.textLayout.events |
| 類別 | public class TextLayoutEvent |
| 繼承 | TextLayoutEvent Event Object |
| 子類別 | ScrollEvent |
| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
TextLayoutEvent.SCROLL 事件),該事件不需要自訂屬性。
捲動事件是由 type 屬性設定為 TextLayoutEvent.SCROLL 的 TextLayoutEvent 實體表示。並不需要專門用於捲動事件的類別,因為捲動事件沒有自訂屬性,而其他具有特定事件類別的事件則具有自訂屬性。如果需要新的文字版面事件,且事件不需要自訂屬性,則新事件也會由 TextLayoutEvent 物件表示,但該事件的 type 屬性則是設定為新的靜態常數。
公用方法
| 方法 | 定義自 | ||
|---|---|---|---|
TextLayoutEvent 類別代表傳遞給許多 Text Layout 事件之事件偵聽程式的事件物件。 | TextLayoutEvent | ||
![]() |
複製 Event 子類別的實體。 | Event | |
![]() |
公用程式函數,可用來實作自訂 ActionScript 3.0 Event 類別中的 toString() 方法。 | Event | |
![]() |
指出物件是否有已定義的指定屬性。 | Object | |
![]() |
檢查是否已經對事件呼叫 preventDefault() 方法。 | Event | |
![]() |
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | |
![]() |
如果可以取消事件的預設行為指令,則取消該行為指令。 | Event | |
![]() |
指出指定的屬性是否存在,以及是否可列舉。 | Object | |
![]() |
為迴圈作業設定動態屬性的可用性。 | Object | |
![]() |
避免處理事件流程中,目前節點以及任何後續節點中的任何事件偵聽程式。 | Event | |
![]() |
避免處理接續在事件流程中的目前節點之後,後續節點中的任何事件偵聽程式。 | Event | |
![]() |
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | |
![]() |
傳回包含 Event 物件所有屬性的字串。 | Event | |
![]() |
會傳回指定之物件的基本值。 | Object | |
公用常數
| 常數 | 定義自 | ||
|---|---|---|---|
| SCROLL : String = "scroll" [靜態]
TextLayoutEvent.SCROLL 常數定義了捲動事件之事件物件的 type 屬性值。 | TextLayoutEvent | ||
建構函式詳細資料
TextLayoutEvent | () | 建構函式 |
常數詳細資訊
SCROLL | 常數 |
public static const SCROLL:String = "scroll"| 語言版本: | ActionScript 3.0 |
| 執行階段版本: | Flash Player 10, AIR 1.5 |
TextLayoutEvent.SCROLL 常數定義了 scroll 事件之事件物件的 type 屬性值。
範例 如何使用本範例
TextLayoutEvent_example.as
這個範例會顯示如何建立一個用於偵聽捲動事件的事件處理常式。兩個主要步驟是在文字流排上呼叫
addEventListener() 方法,以及建立事件處理常式函數。
在 TextFlow 實體上呼叫 addEventListener() 方法。 您可以使這個簡易字串 "text",但是最好使用靜態常數 TextLayoutEvent.SCROLL
此範例中的事件處理常式函數命名為 scrollEventHandler()。只要偵測到捲動事件,事件處理常式就會執行 trace() 陳述式。 這個範例不包括一個捲軸,但是當使用者反白文字並往下拖曳游標超過容器的底部後,就會捲動文字。
package flashx.textLayout.events.examples {
import flash.display.Sprite;
import flash.events.Event;
import flashx.textLayout.compose.StandardFlowComposer;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.events.TextLayoutEvent;
import flashx.undo.UndoManager;
public class TextLayoutEvent_example extends Sprite
{
private const textMarkup:String = "<flow:TextFlow xmlns:flow='http://ns.adobe.com/textLayout/2008' fontSize='14' " +
"textIndent='10' paragraphSpaceBefore='6' paddingTop='8' paddingLeft='8' paddingRight='8'>" +
"<flow:p paragraphSpaceBefore='inherit'>" +
"<flow:span>There are many </flow:span>" +
"<flow:span fontStyle='italic'>such</flow:span>" +
"<flow:span> lime-kilns in that tract of country, for the purpose of burning the white" +
" marble which composes a large part of the substance of the hills. Some of them, built " +
"years ago, and long deserted, with weeds growing in the vacant round of the interior, " +
"which is open to the sky, and grass and wild-flowers rooting themselves into the chinks" +
"of the stones, look already like relics of antiquity, and may yet be overspread with the" +
" lichens of centuries to come. Others, where the lime-burner still feeds his daily and " +
"nightlong fire, afford points of interest to the wanderer among the hills, who seats " +
"himself on a log of wood or a fragment of marble, to hold a chat with the solitary man. " +
"It is a lonesome, and, when the character is inclined to thought, may be an intensely " +
"thoughtful occupation; as it proved in the case of Ethan Brand, who had mused to such " +
"strange purpose, in days gone by, while the fire in this very kiln was burning.</flow:span>" +
"</flow:p>" +
"</flow:TextFlow>";
public function TextLayoutEvent_example()
{
// create the TextFlow, container, and container controller
var textFlow:TextFlow;
var container:Sprite = new Sprite();
var _controller:ContainerController = new ContainerController(container, 200, 100);
// import the text flow from markup using TextFilter and assign a StandardFlowComposer
textFlow = TextConverter.importToFlow(textMarkup, TextConverter.TEXT_LAYOUT_FORMAT);
textFlow.flowComposer = new StandardFlowComposer();
// create undo, edit and interaction managers
var _undoManager:UndoManager = new UndoManager();
var _editManager:EditManager = new EditManager(_undoManager);
textFlow.interactionManager = _editManager;
// Add container to display list
addChild(container);
container.x = 25;
container.y = 100;
// Add an event listener for the TextLayoutEvent.SCROLL event
textFlow.addEventListener(TextLayoutEvent.SCROLL, scrollEventHandler);
// add the controller to the text flow and update it to display the text
textFlow.flowComposer.addController(_controller);
textFlow.flowComposer.updateAllControllers();
}
private function scrollEventHandler(evt:Event):void {
trace ("scroll event occurred");
}
}
}
Tue Jun 12 2018, 03:47 PM Z
隱藏繼承公用屬性
顯示繼承公用屬性