Answered
Problem with creating a container with single text line
Hi~
I'm crushed with a following problem.
Problem: I need to create a container with a single text line. As i learn from the TLF API, there's no way to do that so it left only a way that's like this:
//Assuming textFlow object is create
var container:Sprite = new Sprite();
var width:Number = 500; // it's specified value
var height:Number = 300; // just estimating it's enought for a normal single line height
var controller:DisplayObjectContainerController = new DisplayObjectContainerController(container, width, height);
controller.verticalScrollPolicy = ScrollPolicy.OFF;
textFlow.flowComposer.addController(controller); textFlow.flowComposer.composeContainer(textFlow.flowComposer.getControllerIndex(controller));
// find top first line in the created container
var textFlowLine:TextFlowLine= textFlow.flowComposer.findLineAtPosition(controller.absoluteStart, false);
var calLineHeight:Number = textFlowLine.textHeight+8; // here 8 is just a test value
controller.setCompositionSize(width, calLineHeight);
textFlow.flowComposer.updateContainer(_textFlow.flowComposer.getControllerIndex(controller));
In this way, it first calculate first line height giving enough space to the controller
and composing, after that it adjust the container height again then updates.
It's so much overhead i guess
So anybody have more simple or right way to do?
I'm crushed with a following problem.
Problem: I need to create a container with a single text line. As i learn from the TLF API, there's no way to do that so it left only a way that's like this:
//Assuming textFlow object is create
var container:Sprite = new Sprite();
var width:Number = 500; // it's specified value
var height:Number = 300; // just estimating it's enought for a normal single line height
var controller:DisplayObjectContainerController = new DisplayObjectContainerController(container, width, height);
controller.verticalScrollPolicy = ScrollPolicy.OFF;
textFlow.flowComposer.addController(controller); textFlow.flowComposer.composeContainer(textFlow.flowComposer.getControllerIndex(controller));
// find top first line in the created container
var textFlowLine:TextFlowLine= textFlow.flowComposer.findLineAtPosition(controller.absoluteStart, false);
var calLineHeight:Number = textFlowLine.textHeight+8; // here 8 is just a test value
controller.setCompositionSize(width, calLineHeight);
textFlow.flowComposer.updateContainer(_textFlow.flowComposer.getControllerIndex(controller));
In this way, it first calculate first line height giving enough space to the controller
and composing, after that it adjust the container height again then updates.
It's so much overhead i guess
So anybody have more simple or right way to do?
