Any update on paragraph backgroundColor?
Hello there,
This is a question to TLF team.
Sometime ago Robin mentioned that eventually 'backgroundColor' for paragraph would be implemented.
Any updates on that?
Thanks,
Igor Borodin
Hello there,
This is a question to TLF team.
Sometime ago Robin mentioned that eventually 'backgroundColor' for paragraph would be implemented.
Any updates on that?
Thanks,
Igor Borodin
Thank you, Jin-Huang, for the hint.
I didn't know that although 'backgroundColor' is not implemented, it's nevertheless is stored and thus is accessible.
That's definite help.
Now could you clarify for me how to access individual paragraph's x, y, width, and height properties?
When I try something like this:
<myRichEditableText.textFlow.flowComposer.numControllers>
it returns '1', although there are multiple paragraphs.
Consequently, if I try:
<myRichEditableText.textFlow.flowComposer.getControllerAt(0).getContentBounds()>
it returns the values for the entire text.
So, how can I read the x, y, width, and height of individual paragraphs?
Thanks,
Igor Borodin
Here is one way to find the first paragraph's boundary. Also there are many other ways. The point is how to get the TextFlowLine(TLF object, related to a TextLine in the container, include more information than TextLine)/TextLine(FTE object or engine object, the actual lines added to the container and show on the screen, has less info).
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="getInfo()">
<fx:Script>
<![CDATA[
import flashx.textLayout.compose.IFlowComposer;
import flashx.textLayout.compose.TextFlowLine;
function getInfo():void{
var firstPara:ParagraphElement = rt.textFlow.getChildAt(0) as ParagraphElement;
var composer:IFlowComposer = rt.textFlow.flowComposer;
var firstLineInFirstPara:TextFlowLine = composer.findLineAtPosition(0);
var x:Number = firstLineInFirstPara.x;
var y:Number = firstLineInFirstPara.y;
var lastLineInFirstPara:TextFlowLine = composer.findLineAtPosition(firstPara.textLength-1);
var width:Number = rt.width;// You can also get the width from the widest textline
var height:Number = lastLineInFirstPara.y - y + lastLineInFirstPara.height;
rt.graphics.lineStyle(1, 0);
rt.graphics.drawRect(x,y,width,height);
}
]]>
</fx:Script>
<s:RichEditableText id="rt" width="100">
<s:content>
<s:p>The following example shows how you can import a TextFlow object from an XML object in Flex 4 by using the static</s:p><s:p>The following example shows how you can import a TextFlow object from an XML object in Flex 4 by using the static</s:p>
</s:content>
</s:RichEditableText>
</s:Application>
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.