• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Scroll to TextLine

New Here ,
Sep 03, 2009 Sep 03, 2009

Copy link to clipboard

Copied

Hi there,

I have this list of pararaphs, that in my application stand for the start of a new page, I put these in a little combobox so the user can jump between pages in my app by selecting an item. (The whole TextFlow is in one container). By selecting an item, the specified paragraph then scrolls to the top of the container.

I thought this mechanism was easy enough to implement, like this:

var startPos:int = paragraphElement.getAbsoluteStart();

var tfl:TextFlowLine = textFlow.flowComposer.findLineAtPosition(position);
containerController.verticalScrollPosition = tfl.y;

Now, this works like a charm for the first couple of paragraphs, but later on the textflowline has a y property of 0.

I understand now that this is, of course, because these lines haven't been drawn yet.

So, obviously I'm using the wrong technique for this, therefore my question:

Is there a different way of scrolling an arbitrary paragraph in your textflow to the top of your container?

Any help will be greatly appreciated, thanks in advance!

cheers,

Roland

TOPICS
Text layout framework

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Sep 04, 2009 Sep 04, 2009

Use composeToPosition instead of scrollToPosition and then use your logic to scroll to the TextLine.  There is another API getScrollDelta on ContainerController that may be useful.

Richard

Votes

Translate

Translate
Adobe Employee ,
Sep 03, 2009 Sep 03, 2009

Copy link to clipboard

Copied

Use containerController.scrollToRange(startPos,startPos);

The text isn't composed yet because TLF stops composing after the end of the visible text.  The TextFlowLine is a placeholder with all the overflow text in it and no computed location.

Richard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2009 Sep 04, 2009

Copy link to clipboard

Copied

Hey Richard,

thanks for taking the time to reply.

I had already tried scrollToRange(), but it doesn't do precisely what I need. It scrolls the necessary text into view. Whereas I need to have the first line of the paragraph to be exactly at the top of my container.

Right now I did a bit of an ugly hack, but it works for now, I first call scrollToRange() (then I'm certain the textflow will have been composed) and then I call my other code to position it to the top of the container.

It ain't pretty, but for now it works   I've looked at the source for scrollToRange(), which is about a page of adding and substracting all kinds of positions, so when I find a bit more time I'll try to analyze that and come up with a 'clean' way of scrolling to the top.

cheers,

Roland

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 04, 2009 Sep 04, 2009

Copy link to clipboard

Copied

Use composeToPosition instead of scrollToPosition and then use your logic to scroll to the TextLine.  There is another API getScrollDelta on ContainerController that may be useful.

Richard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2009 Sep 04, 2009

Copy link to clipboard

Copied

Hi Richards,

thanks for the info, I'll be sure to try that out!

cheers,

Roland

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2010 Jul 09, 2010

Copy link to clipboard

Copied

LATEST

You guys are right, the solution is very hacky, but it does work quite well...

_objFlow.flowComposer.composeToPosition(objEx.StartIndex);

var tfl:TextFlowLine = _objFlow.flowComposer.findLineAtPosition(objEx.StartIndex);

_objController.verticalScrollPosition = Math.max(tfl.y - 40, 0);

TextLayout Team, why not add a option bool parameter to findLineAtPosition to allow us to force the compose to position within that single operation.  Additonally I would love to see a method added to the DisplayContainerController along the lines of ScrollToPosition(iCharPosintion:int, nYOffset:Number = 0, bForceComposeToPosition:Boolean = false);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines