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

How can I detect when the last container in my flow is full?

Community Beginner ,
Apr 14, 2010 Apr 14, 2010

I have a bunch of linked containers which I am flowing text through. How can I detect when the text has filled a container? there's an overflowPolicy so I assume this can be detected.

TOPICS
Text layout framework
836
Translate
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

Participant , Apr 14, 2010 Apr 14, 2010

Hi,

I used this :

private function IsOverset(textFlow:TextFlow):Boolean

{

var zeComposer:IFlowComposer=textFlow.flowComposer;

var iTextLen:int=textFlow.textLength;

var iNoController:int=zeComposer.findControllerIndexAtPosition(iTextLen - 1);

return (iNoController == -1);

}

HTH,

J.

Translate
Participant ,
Apr 14, 2010 Apr 14, 2010

Hi,

I used this :

private function IsOverset(textFlow:TextFlow):Boolean

{

var zeComposer:IFlowComposer=textFlow.flowComposer;

var iTextLen:int=textFlow.textLength;

var iNoController:int=zeComposer.findControllerIndexAtPosition(iTextLen - 1);

return (iNoController == -1);

}

HTH,

J.

Translate
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
Community Beginner ,
Apr 14, 2010 Apr 14, 2010

Hey! That might just work! thanks for your response.

🙂

Translate
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
Community Beginner ,
Apr 14, 2010 Apr 14, 2010

short lived I'm afraid. I only ever get -1 with this ...

var containerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength);
                    if(containerIndex==-1) textFlowCompleteHandler();

I'm detecting this as the flow is created. The textFlow.length is being set correctly.

Any ideas?

Translate
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
Community Beginner ,
Apr 14, 2010 Apr 14, 2010

So I fixed that issue ...

var containerIndex:int = textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength-1);
                if(containerIndex==-1) textFlowCompleteHandler();

... by using textLength-1 to give me the last character in my flow.

BUT it now doesn't give me -1 ever. Even when the text has flown through the last container. I guess my container is still being used by the flow. Do I need to set the container so it doesn't allow scrolling or something like that?

Translate
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 ,
Apr 14, 2010 Apr 14, 2010

I'd do this a different way.  Not exactly what you want but similar.  This code adds containers until all the text in the TextFlow belongs to some container.

for (;;)

{

    var controller:ContainerController = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1)

    if (controller && controller.absoluteStart+controller.textLength == textFlow.textLength)

        break;  // ALL DONE

    controller = new Controller(new Sprite,somewidth,someheight)

    // turn off scroll policy else all overflow text goes in the last container

    controller.verticalScrollPolicy = controller.horizontalScrollPolicy = ScrollPolicy.OFF;

    textFlow.flowComposer.addController(controller);

    textFlow.flowComposer.updateAllControllers();

}

Didn't compile this but I just wrote something similar (its on a different machine that I can't get to right now).

Also reccomend getting TLF 1.1 for this algorithm as its much more efficient for this type of thing than TLF 1.0.

Hope that helps,

Richard

Translate
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
Participant ,
Apr 15, 2010 Apr 15, 2010

Yes, if my memory is right, you need to disable scrolling in the container. Otherwise, the whole text will flow in the container and there will never be an overflow of course...

I used this when adding controller :

var

aCC:ContainerController=new ContainerController(aFrame.zeSprite, iCW, iCH);

aCC.verticalScrollPolicy=

'off';

Maybe some problems may occur because of possibly asynchronous composition (but I'm not really sure).

J.

Translate
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
Community Beginner ,
Apr 15, 2010 Apr 15, 2010
LATEST

I've just tested this and you're correct. I set the Scrollpolicy to OFF for

all my controllers and now when I run this code after each FlowElement

object is created and added to my TextFlow it will detect when the element

is no longer within a container ...

var containerIndex:int =

textFlow.flowComposer.findControllerIndexAtPosition(textFlow.textLength-1);

if(containerIndex==-1) textFlowCompleteHandler();

Thanks for the help guys.

Also, I found that this ...

config.overflowPolicy = OverflowPolicy.FIT_DESCENDERS;

... now works as expected. Before I set the scroll policy to OFF the last

line of my flow was cut off at the bottom of the container.

Translate
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