Skip to main content
Inspiring
March 18, 2009
Answered

Grab last container

  • March 18, 2009
  • 7 replies
  • 908 views
Hi All,

I have a textflow, and i put some paragraph element, span, div element. Then now i want to catch the last container in order to put an inline text. Do you have any ideas ? I am new bie,,so at first i thought it this way:



But it doesn't work.

Thank you for your answer,

-Hoang Long
This topic has been closed for replies.
Correct answer texttile
;) it seems i got it,..but it is still nice if i have your confirmation.
From the textFlow tree in Text Layout Framework, we can ensure that the parent of any leafElement is a paragraph. (LeafElement can only be Graphic, Span, Link, TCY). So i can just do this way:

return this._textFlow.getLastLeaf().getParagraph();

What do you think?

Bests,

-Hoang Long

7 replies

Adobe Employee
March 18, 2009
Link and TCY are not leaf elements. However, getParagraph is exactly what you want.

this._textFlow.getLastLeaf().getParagraph(); returns the final ParagraphElement in the TextFlow.

Richard
texttileAuthorCorrect answer
Inspiring
March 18, 2009
;) it seems i got it,..but it is still nice if i have your confirmation.
From the textFlow tree in Text Layout Framework, we can ensure that the parent of any leafElement is a paragraph. (LeafElement can only be Graphic, Span, Link, TCY). So i can just do this way:

return this._textFlow.getLastLeaf().getParagraph();

What do you think?

Bests,

-Hoang Long
Adobe Employee
March 18, 2009
Use the absoluteStart and textLength of the controller to find a FlowElement in the TextFlow.

var elem:FlowLeafElement = _textFlow.findLeaf(controller.absoluteStar+controller.textLength-1)

Now you know the last element in the container. From there find the paragraph and manipulate the flow according to your needs. There is a rich set of APIs for mapping absolute positions between containers and its textflow and for navigating and manipulating the TextFlow.

Maybe I don't understand what you are trying to do though.


Richard
texttileAuthor
Inspiring
March 18, 2009
so what is the next step after i have _textFlow.flowComposer.getControllerAt. as your suggestion? Because now it is IContainerController and,, there is no "addChild" method in this object as we used to do when we have div or paragraph element ?
Adobe Employee
March 18, 2009
Sounds like the correct approach.

Richard
texttileAuthor
Inspiring
March 18, 2009
Hi Richard,

Thank you for your answer. It seems i haven't found a solution for myself.
Using our code, then i will get IContainerController. Then i can't find a way to add a child which is,,,example a span element,,to have inline text.

Could you tell me how to do it?

An example: i have a textFlow; then i added paragraph. In paragraph i added tow childs span and graphic. Now i would like to have one inline text added. The way to do is to look for the Paragraph, and add one more child which is the span element.

Or you may have other ideas to put an inline text into the textflow tree?

Regards,

-Hoang Long







Adobe Employee
March 18, 2009
I think you want to look at the container controllers in _textFlow.flowComposer. The fastest way to get there is to call
_textFlow.flowComposer.findControllerIndexAtPosition(_textFlow.textLength,true);
Use the returned index as a parameter to _textFlow.flowComposer.getControllerAt.

The API you are looking at is for finding the parent subclass of ContainerFormattedElement. It will just return the _textFlow

Richard