I'm trying to implement dropped initials feature into my Flex application. Since Text Layout Framework does not su开发者_开发技巧pport floating, the only known solution is to create additional containers that will be linked together, displaying the same textflow. Width and positioning of these containers has to be set in such a way that it will pretend that it's float.
I'm using the same solution for dropped initials. Basically, I'm creating three containers, one for the initial letter (first letter in text flow), the other for text floating around, and the 3rd one to display text below these two. All these containers share one textflow.
I have big issues with forcing controller to display only one letter from the text flow, and size it accordingly, so that it wont take any unnecessary aditional space and won't get any more text into it.
Using ContainerController.getContentBounds() returns me size of whole sprite of the letter (with ascent/descent empty parts), not the height/width of the actual rendered letter. I'm using textFlow.flowComposer.getLineAt(0).getTextLine().getAtomBounds(0), but i think it's still not right. Also, even if I set container for this dimensions, it sometimes display additional text in it, especially for bigger fonts. See screen :
alt text http://img97.imageshack.us/img97/6105/tlfissue.png
Also, if I set width to just 1px less that contentBounds, things are going crazy, containers are moved around, positioned with big margins, etc.
How should I solve this? Is it a bug in TLF / Player? Can I fix it somehow? Can I detect the size of the letter, or make containercontroller autosize to fit just one letter only?
What you need to do is to set columnBreakAfter to BreakStyle.ALWAYS. This would mean that your single letter would need to be in its own SpanElement inside of of a ParagraphElement.
Example:
var p:ParagraphElement = new ParagraphElement();
p.columnBreakAfter = BreakStyle.ALWAYS; //Forces a break in the container
var span:SpanElement = new SpanElement();
span.text = "A";
p.addChild(span);
精彩评论