Skip to main content
Inspiring
September 22, 2009
Question

AutoScrolling Performance

  • September 22, 2009
  • 1 reply
  • 1203 views

If you create a textflow with a single container.

Then onEnterframe append a new div to the textflow.

Then add a selection manager to add scrolling capability.

The performance degrades the further down the container you scroll.

If I remain with the first line of text at the top of the container, even after adding 10000 divs the performance remains stable - adding 100 divs every 4 seconds. If I turn off the onEnterFrame at that point I can still smoothly scroll the text in the container using the mouse wheel.

However, when I turn the onEnterFrame back on and keep appending divs,  the performance degrades according to how many lines I have scrolled down in the container.

If you set the vertical scroll policy to VerticalAlign.BOTTOM, then you can see the result of this degradation quite quickly.

Is there an efficient way to append text to a textflow and have the container align its content to the bottom?

I only want to append text to the end of the flow. I imagine it would require some logic like: TextFlow.flowComposer.composeFromPosition() as opposed to TextFlow.flowComposer.composeToPosition() Since I know that only the end of the text flow will be altered.

Since I am only using a single container is there a simpler set up?

Thanks,

Josh

example code attached


This topic has been closed for replies.

1 reply

Adobe Employee
September 22, 2009

It's a known problem - really what's needed is a better way to restart composition in the middle of the content.  This will not be fixed for the first release.

The best workaround for now is to page through multiple containers like the pagination example from the blog.

http://blogs.adobe.com/tlf/2008/12/actionscript-pagination-exampl.html

Hope that helps,

Richard

josh_onAuthor
Inspiring
September 24, 2009

Thanks Richard,

I am going to need to get that to work.  I looked at the code and saw that in BaseCompose composeTextFlow there is a line: _curElement = _rootElement.getFirstLeaf(); which sets the start point of the composition.  I was thinking of extending ComposeState, and StandardFlowComposer to add some functions that would just compose from a certain point.  However when I started to do this and compile against the 427 build that I was using as my swc I realised that it was not going to work because I don't think that ComposeState existed in that build.  I tried to compile against two later builds: 470, and 502 - but in those, before even building in any extra classes, the code that I wrote for the example above doesn't work as I expected.

In 427 this code:

cc = new ContainerController(text_container, 400, 200);

cc.verticalAlign = VerticalAlign.BOTTOM;

will cause the text to automatically scroll after new text is added and updateAllContainers is called.

eg:

var d:DivElement = new DivElement();

var p:ParagraphElement = new ParagraphElement();

var span:SpanElement = new SpanElement();

span.fontSize = Math.round(Math.random() * 10) + 8;

span.fontWeight = (count%3 == 0)? FontWeight.BOLD :FontWeight.NORMAL;

span.text = "Count " + String(count) +" a line of text or two goes here a line of text or two goes here a line of text or two goes here";

p.addChild(span);

d.addChild(p);

text_flow.addChild(d);

text_flow.flowComposer.updateAllControllers();

In the later versions it doesn't seem to align the bottom of the text to the bottom of the container. 

I haven't tried to see why, first I wanted to know if this is a bug or expected behavior.

I also wanted to know which build I should work with if I extend these classes. 

Thanks again for your help,

Josh

Adobe Employee
September 25, 2009

None of the classes have gone away.  ComposeState is not accessible from outside the textLayout swc so I don't think you can make these changes on the outside.  I'm not aware of any vertical alignment problems.  Auto scrolling will happen to keep the selection in view.

The nature of the changes is twofold 1) reinitializing the composer's state so that it can start in the middle 2) figuring out when the compose should start in the middle.  Lots of detail to get that working though.

Richard