Skip to main content
January 6, 2011
Question

How can we simulate the Indesign paragraph rules in Adobe Flex4?

  • January 6, 2011
  • 1 reply
  • 1287 views

Hi,

http://help.adobe.com/en_US/indesign/cs/using/WSa285fff53dea4f8617383751001ea8cb3f-6dc1a.html

The above link specifies how Paragraph Rules are added in InDesign.

I have a scenario where I would want the same thing to happen in Flex.

So is there any thing that can be done in Adobe Flex 4 in TLF 1.1 so that we can add these rules in the view generated using Flex.

I was initially thinking of using inline graphics but I it will not help my cause.

Please share if there is any way out

Thanks

Ashar

This topic has been closed for replies.

1 reply

Adobe Employee
January 6, 2011

Interesting problem! Here's a suggestion to try.

Make your own ContainerController class that derives from ContainerController and overrides the addTextLine protected method. Each time a line is added, check it to see if it is the first or last line of the paragraph (assuming you wanted rules above and below). If so, then create a new DisplayObject for the rule, and make the rule a child of the TextLine. Then call super.addTextLine, which will add the TextLine to the container. To determine whether the line is first or last, get the TextFlowLine from the TextLine's userData. The TextFlowLine has a location property which will tell you if the line is first, last, middle, or only. To get TLF to use your derived ContainerController class, pass in one of your ContainerController's when you call addController on the textFlow's flowComposer.

So, your code might look something like this:

textFlow.flowComposer.addController(new RuleContainerController(sprite, width, height));

class RuleContainerController extends ContainerController

{

     override protected function addTextLine(textLine:TextLine, index:int):void

     {

          var line:TextFlowLine = textLine.userData as TextFlowLine;

          if (line.location & TextFlowLine.LAST)

          {

               ruleAfter:DisplayObject = // set up the rule here

               textLine.addChild(ruleAfter);

          }

          super.addTextLine(textLine, index);

     }

This code will add a rule to every paragraph, which may not be what you want. But you could add a user property that you add to the paragraph, and then the addTextLine could use the TextFlowLine to get the paragraph and only attach the rule if property is set.

This is really just sketched out, I haven't compiled or debugged it or anything, but it seems like it might work for your problem. Let me know how it works!

- robin

January 7, 2011

Hi,

I was actually wondering whether flex doesnt have some thing by itself for this.

I will try to get somewhere with your approach and will let you know if that solves it,thanks any ways .

Ashar

Adobe Employee
January 7, 2011

I mostly work with TLF itself, so I'm not a Flex expert. The only Flex oriented solution I can think of is to separate the text into different components around where you want the rules, and then make the rules their own component. But that has its own downsides, especially if you either have a lot of text, or if you're trying to maintain it in a back end database.

You could try reposting this in the Flex forum and see if the folks there have any suggestions.

- robin