Skip to main content
Participating Frequently
October 26, 2011
Answered

RangeError: Error #2006 when calling updateAllControllers()

  • October 26, 2011
  • 1 reply
  • 1114 views

Hi, up to yesterday I had a problem where an index out of bounds exception (Error #2006) was thrown after doing a compose()/updateAllControllers() cycle several times, with no apparent reason. Here's the first part of the stack trace (after that just comes the line where updateAllControllers was invoked):

RangeError: Error #2006: El índice proporcionado está fuera de los límites.

    at flash.display::DisplayObjectContainer/addChildAt()

    at flashx.textLayout.container::ContainerController/addTextLine()

    at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::updateCompositionShapes()

    at flashx.textLayout.compose::StandardFlowComposer/updateCompositionShapes()

    at flashx.textLayout.compose::StandardFlowComposer/updateToController()

    at flashx.textLayout.compose::StandardFlowComposer/updateAllControllers()

I tried to follow the code of ContainerController and StandardFlowComposer, but it was no use. I couldn't get the debugger to work with those files either.

I compared side by side the values of the relevant attributes of the textFlow's flowComposer and of its controllers (composition width and height, absoluteStartPosition, etc.) right before a successful call to updateAllControllers() and just before a call that would fail, and they were absolutely the same.

Finally I solved the problem in a really weird (and not very clean) way: adding and removing one controller from the flowComposer just before issuing the call to updateAllControllers() or compose() (in another part of my code).

if (this._textFlow.flowComposer.numControllers > this._columnas - 1 && this._containers[this._columnas - 1].visible)

{

     this._textFlow.flowComposer.removeControllerAt(this._columnas - 1);

     this._textFlow.flowComposer.addControllerAt(this._controllers[this._columnas - 1], this._columnas - 1);

}

           

this._textFlow.flowComposer.compose();

this._textFlow.flowComposer.updateAllControllers();

So, my questions are: which are the factors that could lead to that exception when updateAllControllers() or compose() are called? Does adding and/or removing a controller from the flowComposer change some internal attribute (that was left in an inconsistent state)? Could this be a bug in the framework?

Sorry for not posting the whole code, but it involves several custom classes and its working is quite complex. I tried to reproduce the error in a reduced context, but I couldn't.

Thanks in advance!

This topic has been closed for replies.
Correct answer Jin-Huang

Is there a "clean" way to force a full recomposition of the TextFlow?

textFlow.flowComposer.damage(0,textFlow.textLength,flashx.textLayout.compose.FlowDamageType.INVALID /* or GEOMETRY, choose one that can meet your requirment*/);

textFlow.flowComposer.updateAllControllers();

1 reply

Adobe Employee
October 27, 2011

You need not call compose() before updateAllControllers().

If you remove a controller and then add it back, when calling updateAllControllers(), the whole textflow will be composed again from the very beginning.

I think the range error happens when some items are supposed to be on the container, actually not there. It's probably a special case that tlf did not handle. But if there is no simple project can reproduce it, we cannot fix it. Besides, no one else has ever reported such an issue before.

Which version of SDK are you using? TLF 3.0 final version will be released in Nov. Maybe you can have a try.

latamykAuthor
Participating Frequently
October 27, 2011

Thanks for your answer, it was very helpful.

If you remove a controller and then add it back, when calling updateAllControllers(), the whole textflow will be composed again from the very beginning.

This helps a lot explain why it works when I add and remove a controller. Is there a "clean" way to force a full recomposition of the TextFlow? (I mean, a method of the TextFlow or the FlowComposer that acomplishes this without having to add/remove a controller).

I think the range error happens when some items are supposed to be on the container, actually not there. It's probably a special case that tlf did not handle.

Now that you mention it, the number of lines varied a little across the different calls, but before the error happened it was the same as in the beginning.

But if there is no simple project can reproduce it, we cannot fix it.

I understand. The thing is complicated because the TextFlow instance is being shared between a class representing a news article with several pages (controllers) and another class that represents the first page of that article, which in turn owns another set of controllers. Besides, the resizing logic has to pay attention to many things.

Which version of SDK are you using? TLF 3.0 final version will be released in Nov. Maybe you can have a try.

I'm using the 3.0 version released on September 19th. I'll give the November version a try then, a former problem I had with links was solved by moving to a newer version.

Jin-HuangCorrect answer
Adobe Employee
October 28, 2011

Is there a "clean" way to force a full recomposition of the TextFlow?

textFlow.flowComposer.damage(0,textFlow.textLength,flashx.textLayout.compose.FlowDamageType.INVALID /* or GEOMETRY, choose one that can meet your requirment*/);

textFlow.flowComposer.updateAllControllers();