Skip to main content
Participant
March 16, 2009
Answered

one texlayout below anther

  • March 16, 2009
  • 1 reply
  • 424 views
hello,
i need to put two textlayout with dynamic text one below anther, how do i know what y to give to the last one?
(i think i need some way to calclate the height of the first textlayout after the dynamic text is inserted to it... ( i can't do it in one textlayout, cause i want a radio button to be exactly near the second textlayout) )
This topic has been closed for replies.
Correct answer robin_briggs
The easiest way to do this is to use Flex. There are a set of text components that come with Gumbo that will do much of this logic for you. Flex is open source, and I think there are links to it in the FAQ.

But if you have your own reasons for coding it yourself, here are some pointers.

After the text has been displayed, you can get the contentHeight from the container controller. Here's an example of what this might look like, given a textFlow:

var currentPosition:Number = 0;
var controller:DisplayObjectContainerController = new DisplayObjectContainerController(sprite,width,NaN);
textFlow.flowComposer.addController(controller);
textFlow.flowComposer.updateAllContainers();
controller.container.y = currentPosition;
currentPosition += controller.contentHeight + verticalGap;

Basically, you attach the controller, sizing it to fit all the text. Then you ask it how much text actually fit, and then you'll know where to place the next container.

Hope this helps,

- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
March 17, 2009
The easiest way to do this is to use Flex. There are a set of text components that come with Gumbo that will do much of this logic for you. Flex is open source, and I think there are links to it in the FAQ.

But if you have your own reasons for coding it yourself, here are some pointers.

After the text has been displayed, you can get the contentHeight from the container controller. Here's an example of what this might look like, given a textFlow:

var currentPosition:Number = 0;
var controller:DisplayObjectContainerController = new DisplayObjectContainerController(sprite,width,NaN);
textFlow.flowComposer.addController(controller);
textFlow.flowComposer.updateAllContainers();
controller.container.y = currentPosition;
currentPosition += controller.contentHeight + verticalGap;

Basically, you attach the controller, sizing it to fit all the text. Then you ask it how much text actually fit, and then you'll know where to place the next container.

Hope this helps,

- robin