Skip to main content
Known Participant
Jun 3, 2011 3:38 AM UTC
Answered

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

This topic is closed to new replies. Start a new post to keep the conversation going.
Jin-HuangCorrect answer
Adobe Employee
Jun 7, 2011 2:44 AM UTC

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>

6 replies

Participating Frequently
Jun 3, 2011 7:40 AM UTC

Hi

This feature will not be implemented in 3.0 cycle.

The first priority of TLF is to satisfy the request of our internal customers such as Flex SDK and Flash Authoring. Currently, their request filled our 3.0 schedule and doesn't have the feature you mentioned...

Thanks for your attention

Translate
FTQuestAuthor
Known Participant
Jun 3, 2011 5:36 PM UTC

Thanks for the clarification.

Here is the follow-up question.

I have multiple pieces of text loaded dynamically as markup (i.e. as xml) and rendered in RichEditableText.

In lieu of paragraph background, I draw rectangles with specific coordinates, dimensions, and color as a background for the paragraphs that require that.
So, each instance needs needs 5 numerical pieces of information - x, y, width, height, and color.

What would be your recommendation as to optimal way of including these numeric data in the TextFlow markup (xml) file?

Thanks,

Igor Borodin

Translate
Adobe Employee
Jun 6, 2011 10:19 AM UTC

backgroundColor can be set in the <p> tag, although it does not work now but can be got by p.backgroundColor.

Are x, y, width, height fixed value in your project? Such values in TLF are always stored in the containers. TLF 's job is to layout text in a fixed container. After the text are all layout well, you can get all the textlines' info. I think it will make sense you compute the x, y, width, height after the paragraphs shows up and draw the rectangles.

Translate