Iterating through flowElements in a TextFlow to get their bounds
Hi.
I created a textflow, added a ParagraphElement to it that includes a few SpanElements and InlineGraphicElements..
I've set the flowComposer with a ContainerController, and so far everything is fine: I can see the text and the graphics displayed correctly.
I am listening to the COMPOSITION_COMPLETE event:
(_textFlow.addEventListener(CompositionCompletionEvent.COMPOSITION_COMPLETE, onCompositionComplete);)
on 'onCompositionComplete()' what I want to do is simply iterate through all the elements in the textflow and get their bounds (and other properties)
I've succeeded iterating through the FIRST TextLine's elements like so:
var tfl:TextFlowLine = _textFlow.flowComposer.findLineAtPosition(0); // get first textflowline
var tl:TextLine = tfl.getTextLine(0); // get corresponding textline
var regions:Vector.<TextLineMirrorRegion> = tl.mirrorRegions;
for (var i:int = 0; i < regions.length; i++)
{
// regions.element= the element
// regions.bounds = the bounds of the element
}
I have two questions:
1. How do I get to ALL of the textlines in the flow, so I can iterate through ALL my elements?
2. It seems that the bounds of an InlineGraphicElement are incorrect. I am getting its size, but not its position in the container.
For example, I add my element like so:
var s:Sprite = new Sprite()
s.graphics.lineStyle(1,0,1)
s.graphics.drawRect(0,0,100,15)
ge = new InlineGraphicElement();
ge.source = s; // just a box
ge.height = 15;
ge.width = 100;
p.addChild(ge);
but then when i iterate through the regions (like i said, i managed to do it only for the first textline), the bounds i'm getting are:
left = 0
right = 100
width = 100
height = -15 (btw, why the Minus?)
Obviously, this is not what I want; I want the position of this graphicElement, not its size (which is incorrect - left is not 0).
The size I can already get using regions.element.elementWidth/Height - for bounds I expect to get the position in the textflow container.
Any ideas?
