zoukankan      html  css  js  c++  java
  • textLayout在快速输入清除时报错解决方法

    var tf:TextFlow;

    var len:int = tf.numChildren;
    for (var i:int = 0; i < len; i += 1)
    {
      tf.removeChildAt(0);
    }

    tf.flowComposer.composeToPosition();
    tf.flowComposer.updateAllControllers();

    TypeError: Error #1009: 无法访问空对象引用的属性或方法。
     at flashx.textLayout.edit::ParaEdit$/insertText()       flashx extLayouteditParaEdit.as:54]
     at flashx.textLayout.operations::InsertTextOperation/doInternal()   flashx extLayoutoperationsInsertTextOperation.as:196]
     at flashx.textLayout.operations::InsertTextOperation/doOperation()   flashx extLayoutoperationsInsertTextOperation.as:223]
     at flashx.textLayout.edit::EditManager/doInternal()       flashx extLayouteditEditManager.as:723]
     at flashx.textLayout.edit::EditManager/doOperation()      flashx extLayouteditEditManager.as:603]
     at flashx.textLayout.edit::EditManager/flushPendingOperations()    flashx extLayouteditEditManager.as:873]
     at flashx.textLayout.compose::StandardFlowComposer/updateToController()  flashx extLayoutcomposeStandardFlowComposer.as:554]
     at flashx.textLayout.compose::StandardFlowComposer/updateAllControllers() flashx extLayoutcomposeStandardFlowComposer.as:517]


    tf.interactionManager.selectRange(tf.textLength, tf.textLength);

    TypeError: Error #1009: 无法访问空对象引用的属性或方法。
     at flashx.textLayout.edit::ParaEdit$/insertText()       flashx extLayouteditParaEdit.as:54]
     at flashx.textLayout.operations::InsertTextOperation/doInternal()   flashx extLayoutoperationsInsertTextOperation.as:196]
     at flashx.textLayout.operations::InsertTextOperation/doOperation()   flashx extLayoutoperationsInsertTextOperation.as:223]
     at flashx.textLayout.edit::EditManager/doInternal()       flashx extLayouteditEditManager.as:723]
     at flashx.textLayout.edit::EditManager/doOperation()      flashx extLayouteditEditManager.as:603]
     at flashx.textLayout.edit::EditManager/flushPendingOperations()    flashx extLayouteditEditManager.as:873]
     at flashx.textLayout.compose::StandardFlowComposer/internalCompose()  flashx extLayoutcomposeStandardFlowComposer.as:711]
     at flashx.textLayout.compose::StandardFlowComposer/composeToPosition()  flashx extLayoutcomposeStandardFlowComposer.as:837]

    报错在ParaEdit.as,sibling为null
       var sibling:FlowElement = textFlow.findLeaf(absoluteStart);
       var siblingIndex:int;
       var paragraph:ParagraphElement = sibling.getParagraph();

    问题貌似是因为EditManager.as里insertText方法中的Event.ENTER_FRAME,这个下一帧处理好像会导致快速输入删除时候的不同步
        if (captureLevel == 0 && origOperationState == null && controller && controller.container && allowDelayedOperations)
        {
         enterFrameListener = controller.container;
         enterFrameListener.addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 1.0, true);
        }
        else
         flushPendingOperations();

    我的解决方法是同步处理 不让他下一帧处理 设置 EditManager(tf.interactionManager).allowDelayedOperations = false;

    问题解决 具体为什么 还不是很清楚,先这么用着吧,如果有大神知道,希望可以交流

  • 相关阅读:
    [Android学习系列11]关于Android数据存储的一些事
    [PHP系列1]session和cookie的一些事
    [Android学习系列10]关于Task,Activity,BackStack的一些事
    [Android学习系列9]关于Fragment的一些事
    [Android学习系列8]数据库ormlite笔记
    [Android学习系列7]数据库学习笔记
    JAVA与C++对比 --– 虚函数、抽象函数、抽象类、接口
    iOS常用控件尺寸大集合
    ios 几种快速写法
    一些好的IOS blog 不断增加中。。。。
  • 原文地址:https://www.cnblogs.com/xbglbc/p/3813498.html
Copyright © 2011-2022 走看看