| 包 | flashx.textLayout.events |
| 类 | public class TextLayoutEvent |
| 继承 | TextLayoutEvent Event Object |
| 子类 | ScrollEvent |
| 语言版本: | ActionScript 3.0 |
| 运行时版本: | Flash Player 10, AIR 1.5 |
TextLayoutEvent.SCROLL 事件。
scroll 事件由 type 属性设置为 TextLayoutEvent.SCROLL 的 TextLayoutEvent 实例表示。专用于 scroll 事件的类不是必需的,因为 scroll 事件没有自定义属性,而具有特定事件类的其它事件有自定义属性。如果需要一个新的文本布局事件,而该事件不需要自定义属性,则该新事件也会由一个 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 常量可为 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
此示例说明如何创建事件处理函数,用于侦听 scroll 事件。两个关键的步骤是针对文本流调用
addEventListener() 方法,以及创建一个事件处理函数。
针对 TextFlow 实例调用 addEventListener() 方法。可以使用简单字符串 "text",但是使用静态常量 TextLayoutEvent.SCROLL 更安全。
此示例中的事件处理函数称为 scrollEventHandler()。任何时候检测到 scroll 事件,事件处理函数都会执行 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, 11:04 AM Z
隐藏继承的公共属性
显示继承的公共属性