textLayout在快速輸入清除時報錯解決方法

var tf:TextFlow;對象

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

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

TypeError: Error #1009: 沒法訪問空對象引用的屬性或方法。
 at flashx.textLayout.edit::ParaEdit$/insertText()       flashx\textLayout\edit\ParaEdit.as:54]
 at flashx.textLayout.operations::InsertTextOperation/doInternal()   flashx\textLayout\operations\InsertTextOperation.as:196]
 at flashx.textLayout.operations::InsertTextOperation/doOperation()   flashx\textLayout\operations\InsertTextOperation.as:223]
 at flashx.textLayout.edit::EditManager/doInternal()       flashx\textLayout\edit\EditManager.as:723]
 at flashx.textLayout.edit::EditManager/doOperation()      flashx\textLayout\edit\EditManager.as:603]
 at flashx.textLayout.edit::EditManager/flushPendingOperations()    flashx\textLayout\edit\EditManager.as:873]
 at flashx.textLayout.compose::StandardFlowComposer/updateToController()  flashx\textLayout\compose\StandardFlowComposer.as:554]
 at flashx.textLayout.compose::StandardFlowComposer/updateAllControllers() flashx\textLayout\compose\StandardFlowComposer.as:517]同步


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

TypeError: Error #1009: 沒法訪問空對象引用的屬性或方法。
 at flashx.textLayout.edit::ParaEdit$/insertText()       flashx\textLayout\edit\ParaEdit.as:54]
 at flashx.textLayout.operations::InsertTextOperation/doInternal()   flashx\textLayout\operations\InsertTextOperation.as:196]
 at flashx.textLayout.operations::InsertTextOperation/doOperation()   flashx\textLayout\operations\InsertTextOperation.as:223]
 at flashx.textLayout.edit::EditManager/doInternal()       flashx\textLayout\edit\EditManager.as:723]
 at flashx.textLayout.edit::EditManager/doOperation()      flashx\textLayout\edit\EditManager.as:603]
 at flashx.textLayout.edit::EditManager/flushPendingOperations()    flashx\textLayout\edit\EditManager.as:873]
 at flashx.textLayout.compose::StandardFlowComposer/internalCompose()  flashx\textLayout\compose\StandardFlowComposer.as:711]
 at flashx.textLayout.compose::StandardFlowComposer/composeToPosition()  flashx\textLayout\compose\StandardFlowComposer.as:837]it

 

報錯在ParaEdit.as,sibling爲null
   var sibling:FlowElement = textFlow.findLeaf(absoluteStart);
   var siblingIndex:int;
   var paragraph:ParagraphElement = sibling.getParagraph();io

問題貌似是由於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();date

個人解決方法是同步處理 不讓他下一幀處理 設置 EditManager(tf.interactionManager).allowDelayedOperations = false;List

問題解決 具體爲何 還不是很清楚,先這麼用着吧,若是有大神知道,但願能夠交流select

相關文章
相關標籤/搜索