Skip to main content
February 20, 2009
Answered

Scrolling Issues (Build 370)

  • February 20, 2009
  • 5 replies
  • 1184 views
I'm seeing some really odd behavior with the scrolling related properties on the container controller class in build 370. From what I'm seeing, the values for contentHeight are changing as the verticalScrollPosition changes, even if the content of the text flow has not been modified. This is very evident with a really long text flow in one container. The problem is that the scroll bars are getting new values for content width/height all the time and they end up jumping around a lot as you scroll the container.

Did something change here that I'm overlooking? I'm basically just passing the content sizes and scroll positions straight into the scrollbars, which had always worked fine in the past. Now scrolling can be very erratic. Anyone have ideas?

Thanks,
Brent
This topic has been closed for replies.
Correct answer robin_briggs
Yes, that's right. contentHeight and contentWidth will return an estimate based on how much text is currently composed. If you have a scrolling container, with more text than fits, you may find it is inaccurate. If you want a totally accurate accounting, call composePosition() on the container before accessing contentHeight and contentWidth. It will be slower, but accurate.

5 replies

Participant
February 25, 2009
...but when I comment line
textFlow.lineBreak = LineBreak.EXPLICIT;
typing work more quickly

Vellum: 377 (677136) Release,
Flex: 3.2.0.3958,
Player: WIN 10,0,12,36
Participant
February 24, 2009
Another scroll issue:
I import large text in TextFlow. In start point text typed normally (fast), but when I scroll to bottom of my text, near last line, type speed is very slow. I can write some text and see how letters showes in textflow next few seconds .

Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx=" http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="creationCompleteHandler()">
<mx:Script
source="textSample.as"/> //<--string with large text
<mx:Script>
<![CDATA[
import flashx.textLayout.edit.EditManager;
import flash.text.engine.TabAlignment;
import flashx.textLayout.formats.TabStopFormat;
import flashx.textLayout.formats.LineBreak;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextFilter;
import flashx.textLayout.container.DisplayObjectContainerController;
private function creationCompleteHandler() : void
{
var _textContainer : Sprite = new Sprite();
canvas.rawChildren.addChild( _textContainer );

var _controller : DisplayObjectContainerController = new DisplayObjectContainerController( _textContainer, canvas.width, canvas.height );

TextFlow.defaultConfiguration.manageTabKey = true;

var textFlow : TextFlow = TextFilter.importToFlow( textSample, TextFilter.PLAIN_TEXT_FORMAT );
textFlow.tabStops = createTabs( 10, 30 );
textFlow.lineBreak = LineBreak.EXPLICIT;
textFlow.flowComposer.addController( _controller );
textFlow.interactionManager = new EditManager();


textFlow.flowComposer.updateAllContainers();
}

private function createTabs( count : uint, step : uint ) : Array
{
var tabsArray : Array = [];
var tabStopFormat : TabStopFormat;

for ( var i : uint = 1; i <= count; i++ )
{
tabStopFormat = new TabStopFormat();
tabStopFormat.position = i * step;
tabStopFormat.alignment = TabAlignment.START;

tabsArray.push( tabStopFormat );
}

return tabsArray;
}
]]>
</mx:Script>
<mx:Canvas
id="canvas" width="750" height="480" backgroundColor="#FFFFFF"/>
</mx:WindowedApplication>
Inspiring
February 23, 2009
Robin,
I have a large flow (about 90k) with a good mixture of text, images and links.

I have a scrollbar that I am using in conjunction with a single controller/container sprite attached to a text area to view the text.

After the flow is loaded, and I compose/updateallcontianers, I set the max of the scrollbar to:
bar.maxScrollPosition = cont.contentHeight-textArea.height;
(I also tried bar.maxScrollPosition = cont.contentHeight as well)

Almost always, the scrollbar ends up having a much larger number than the actual contentHeight.

When the text area resizes, it recalculates all of this, and after a couple of restores and maximizes to the browser, the max scroll position and the contentHeight are in sync.

I tried using composePosition instead of compose, and that had no effect. I tried using composePosition after compose and that had no effect.

I am using Gumbo 5022.

Is this a bug?
I can post code if necessary.
Thanks,
Tim
robin_briggsCorrect answer
Adobe Employee
February 23, 2009
Yes, that's right. contentHeight and contentWidth will return an estimate based on how much text is currently composed. If you have a scrolling container, with more text than fits, you may find it is inaccurate. If you want a totally accurate accounting, call composePosition() on the container before accessing contentHeight and contentWidth. It will be slower, but accurate.
February 20, 2009
After investigating this further, I've narrowed it down a bit. It seems that after a partial compose for a container, the getter for contentHeight on the container controller returns an estimated value based on the length of the text flow, the amount of the text flow that has been composed, and the height of the content composed at that point. As you continue to scroll down and more and more of the text flow is composed, the estimate is recalculated taking into account everything composed to that point.

This seems to be a fairly accurate content height estimate if all of the text is similar in size. The issue becomes very apparent when there are lines mid-way through the text flow that are way above average in height. When you scroll down to the point that those taller lines are composed, it throws off the content height estimates and causes the scrollbar to jump around. Once you scroll to the end of the container, the full text flow is composed and the height estimates are accurate.

Is there a way to force a full compose every time for a container or text flow? Seems like that could be one workaround for this issue...