用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: 正在从服务器检索数据...
正在从服务器检索数据...
flashx.textLayout.events 

FlowOperationEvent  - AS3

flashx.textLayout.events
public class FlowOperationEvent
继承FlowOperationEvent Inheritance Event Inheritance Object

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

TextFlow 实例在一个操作开始之前调度该事件,并在操作结束后立即再次调度该事件。尽管这两种情况下调度的事件对象都是 FlowOperationEvent 实例,但是在操作之前和之后调度的事件仍有很大不同。

在执行任何操作之前,TextFlow 对象调度 FlowOperationEvent(其 type 属性设置为 FlowOperationEvent.FLOW_OPERATION_BEGIN)。通过检查 operation 属性,您可以确定将开始执行的操作类型。FLOW_OPERATION_BEGIN 类型的事件是可以取消的,也就是说如果您决定不应该继续执行操作,可以调用 Event.PreventDefault() 取消该操作。如果取消了操作,则不会执行该操作,而且不会调度 FLOW_OPERATION_END 事件。您也可以选择再次调用 EditManager,在完成触发事件的操作之前执行另一操作。如果这样做,则在事件处理函数中启动的操作将作为单个操作被撤消,而替代为触发该事件的操作。

如果要允许继续操作,TextFlow 将在完成该操作(其 type 属性设置为 FlowOperationEvent.FLOW_OPERATION_END)时调度 FlowOperationEvent。在 Flash Player 可能由于该操作而引发任何错误之前调度该事件。这样您有机会在 Flash Player 引发错误之前处理该错误。可以通过事件的 error 属性访问该错误。如果选择在事件处理函数中处理错误,可以通过调用 Event.preventDefault() 取消 FLOW_OPERATION_END 事件来防止 Flash Player 引发错误。您也可以选择再次调用 EditManager 执行某个其它操作。如果这样做,则生成的操作将会作为一个单元被撤消,而替代为触发该事件的操作。

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
 Inheritedbubbles : Boolean
[只读] 表示事件是否为冒泡事件。
Event
 Inheritedcancelable : Boolean
[只读] 表示是否可以阻止与事件相关联的行为。
Event
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 InheritedcurrentTarget : Object
[只读] 当前正在使用某个事件侦听器处理 Event 对象的对象。
Event
  error : Error
在操作期间引发的错误(如果有)。
FlowOperationEvent
 InheritedeventPhase : uint
[只读] 事件流中的当前阶段。
Event
  level : int
可能会通过嵌套将操作合并到合成操作中。
FlowOperationEvent
  operation : FlowOperation
即将开始或刚刚结束执行的操作。
FlowOperationEvent
 Inheritedtarget : Object
[只读] 事件目标。
Event
 Inheritedtype : String
[只读] 事件的类型。
Event
公共方法
 方法由以下参数定义
  
FlowOperationEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, operation:FlowOperation = null, level:int = 0, error:Error = null)
创建事件对象,其中包含有关流操作的信息。
FlowOperationEvent
 Inherited
复制 Event 子类的实例。
Event
 Inherited
formatToString(className:String, ... arguments):String
用于在自定义 ActionScript 3.0 Event 类中实现 toString() 方法的实用程序函数。
Event
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
检查是否已对事件调用 preventDefault() 方法。
Event
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
如果可以取消事件的默认行为,则取消该行为。
Event
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。
Event
 Inherited
防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。
Event
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回一个字符串,其中包含 Event 对象的所有属性。
Event
 Inherited
返回指定对象的原始值。
Object
公共常量
 常量由以下参数定义
  FLOW_OPERATION_BEGIN : String = "flowOperationBegin"
[静态] 定义 flowOperationBegin 事件对象的 type 属性值。
FlowOperationEvent
  FLOW_OPERATION_COMPLETE : String = "flowOperationComplete"
[静态] 定义 flowOperationComplete 事件对象的 type 属性的值。
FlowOperationEvent
  FLOW_OPERATION_END : String = "flowOperationEnd"
[静态] 定义 flowOperationEnd 事件对象的 type 属性值。
FlowOperationEvent
属性详细信息

error

属性
error:Error

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

在操作期间引发的错误(如果有)。如果在操作期间发生了错误,对该错误对象的引用会附加到 FLOW_OPERATION_END 事件。这样您有机会在 Flash Player 引发错误之前处理该错误。如果取消了该事件,Flash Player 不会引发错误。



实现
    public function get error():Error
    public function set error(value:Error):void

level

属性 
level:int

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

可能会通过嵌套将操作合并到合成操作中。此标志描述操作的嵌套级别。



实现
    public function get level():int
    public function set level(value:int):void

operation

属性 
operation:FlowOperation

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

即将开始或刚刚结束执行的操作。



实现
    public function get operation():FlowOperation
    public function set operation(value:FlowOperation):void

相关 API 元素

构造函数详细信息

FlowOperationEvent

()构造函数
public function FlowOperationEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, operation:FlowOperation = null, level:int = 0, error:Error = null)

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

创建事件对象,其中包含有关流操作的信息。

参数
type:String — 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。有两种类型:FlowOperationEvent.FLOW_OPERATION_BEGINFlowOperationEvent.FLOW_OPERATION_END
 
bubbles:Boolean (default = false) — 指示事件是否是冒泡事件。该事件不会冒泡。
 
cancelable:Boolean (default = false) — 表示是否可以阻止与事件相关联的行为。可以通过在事件处理函数中调用 Event.preventDefault() 方法来取消该事件。
 
operation:FlowOperation (default = null) — 要开始执行或刚刚结束执行的 FlowOperation。
 
level:int (default = 0) — 在操作期间生成的任何错误。
 
error:Error (default = null)
常量详细信息

FLOW_OPERATION_BEGIN

常量
public static const FLOW_OPERATION_BEGIN:String = "flowOperationBegin"

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

定义 flowOperationBegin 事件对象的 type 属性值。执行操作之前被调度。取消该事件会阻止操作的执行。

FLOW_OPERATION_COMPLETE

常量 
public static const FLOW_OPERATION_COMPLETE:String = "flowOperationComplete"

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

定义 flowOperationComplete 事件对象的 type 属性的值。在完成所有操作(包括挂起操作和合成操作)、完成合成并滚动显示后调度。

FLOW_OPERATION_END

常量 
public static const FLOW_OPERATION_END:String = "flowOperationEnd"

语言版本: ActionScript 3.0
运行时版本: Flash Player 10, AIR 1.5

定义 flowOperationEnd 事件对象的 type 属性值。在完成操作之后调度。所有错误都存储在 OperationEvent.error 中。如果发生错误,则取消该事件会阻止重新引发错误。一般情况下,所有错误都可能是致命的。

在此时(操作执行后)更改操作可能会失败。

FlowOperationEvent_example.as

此示例说明如何创建事件处理函数,用于侦听文本流操作的开头和结尾。两个关键的步骤是针对文本流调用 addEventListener() 方法,以及创建一个事件处理函数。

addEventListener() 的调用应用于 TextFlow 实例。可以使用简单的字符串“flowOperationBegin”“flowOperationEnd”,但分别使用静态常量 FlowOperationEvent.FLOW_OPERATION_BEGINFlowOperationEvent.FLOW_OPERATION_END 更安全。

此示例中的事件处理函数被命名为 opBeginHandler()opEndHandler()opBeginHandler() 方法使用 trace() 函数来生成一个 trace 语句,用于指示已启动一个粘贴操作。opEndHandler() 方法也使用 trace() 函数,但仅当发生错误时才生成 trace 语句。

package flashx.textLayout.events.examples
{
    import flash.display.Sprite;
    
    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.FlowOperationEvent;
    import flashx.textLayout.operations.FlowOperation;
    import flashx.textLayout.operations.PasteOperation;
    import flashx.undo.UndoManager;

    public class FlowOperationEvent_example extends Sprite
    {
        private var inputContainer:Sprite;
        private var inputTextFlow:TextFlow;
        private var inputController:ContainerController;
        private var inputEditManager:EditManager;
        private var inputUndoManager:UndoManager;

        public function FlowOperationEvent_example()
        {
            var replaceText:String = "paste text here";
            inputTextFlow = new TextFlow();

            inputContainer = new Sprite();
            inputContainer.x = 30;
            inputContainer.y = 100;

             this.stage.addChild( inputContainer );

            inputController = new ContainerController(inputContainer, 225, 20);
            inputController.verticalScrollPolicy = flashx.textLayout.container.ScrollPolicy.OFF;

            inputTextFlow = TextConverter.importToFlow(replaceText, TextConverter.PLAIN_TEXT_FORMAT);
            inputTextFlow.flowComposer = new StandardFlowComposer(); 
            inputTextFlow.flowComposer.addController(inputController);

            inputUndoManager = new UndoManager();
            inputEditManager = new EditManager(inputUndoManager);
            inputTextFlow.interactionManager = inputEditManager;

            inputTextFlow.addEventListener(FlowOperationEvent.FLOW_OPERATION_BEGIN, opBeginHandler);
            inputTextFlow.addEventListener(FlowOperationEvent.FLOW_OPERATION_END, opEndHandler);
            inputTextFlow.flowComposer.updateAllControllers();
        }

        private function opBeginHandler(evt:FlowOperationEvent):void { 
            var flowOp:FlowOperation = evt.operation; 
            if(flowOp is PasteOperation) {
                trace("You can cancel or modify the paste operation in this event handler.");
            }
        }

        private function opEndHandler(evt:FlowOperationEvent):void { 
            var flowOp:FlowOperation = evt.operation; 
            if(evt.error) {
                trace("You can handle the error here and call preventDefault().");
            }
        }
    }
}




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。