Skip to main content
Inspiring
November 2, 2010
Answered

Automatic 'return' after a paragraph

  • November 2, 2010
  • 2 replies
  • 1089 views

It seems to me TLF automatically inserts a 'return' between two paragraphs. So if the first paragraph ends with a return, you get two empty lines between the paragraphs. Is this a correct assumption?

I have been working around this by deleting the last return in a paragraph...

But now (which maybe seems a little bit strange) I want to show two paragraphs without any return, so my work around doesn't do the trick anymore...

Does anybody know if you can turn off the automatic return after a paragraph?

This topic has been closed for replies.
Correct answer robin_briggs

A paragraph always ends a line, and the following text will be in a different line. I don't know of a way to get the effect you want, except for combining the two pieces of text into the same paragraph, or (if they are the complete text) putting them in two separate containers that are placed next to each other.

- robin

2 replies

Known Participant
November 2, 2010

Stefan,

may be the problem is that you are using an HTML paragraph (<P>) since this actually adds a return after each paragraph, I'd recomend you use <BR> instead.

Buabco

Inspiring
November 2, 2010

Thanks for the replies!

I think the "paragraph terminator" is what I would like to bypass...

I've made a short example:


package {
import flash.display.Sprite;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.container.ScrollPolicy;

public class Test2 extends Sprite
{
  public function Test2() {
   var tekstLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
   var cs:Sprite = new Sprite();
  
   addChild(cs);

   var textFlow:TextFlow = new TextFlow();
   textFlow.format = tekstLayoutFormat;

   var tekstveldController = new ContainerController(cs, 400, 400);
   tekstveldController.verticalScrollPolicy = ScrollPolicy.OFF;
   tekstveldController.horizontalScrollPolicy = ScrollPolicy.OFF;

   textFlow.flowComposer.addController(tekstveldController);
   textFlow.flowComposer.updateAllControllers();
  
   var paragraphElement = new ParagraphElement();
   var spanElement = new SpanElement();
   spanElement.text = "text1";
   spanElement.fontSize = 10;
   paragraphElement.addChild(spanElement);
  
   var paragraphElement2 = new ParagraphElement();
   var spanElement2 = new SpanElement();
   spanElement2.text = "text2";
   spanElement2.fontSize = 10;
   paragraphElement2.addChild(spanElement2);
  
   textFlow.addChild(paragraphElement);
   textFlow.addChild(paragraphElement2);

   textFlow.flowComposer.updateAllControllers();
  }
}
}

This test shows:

text1

text2

What I would like to get (maybe strangely enough) is:

text1text2

is this possible?

robin_briggsCorrect answer
Adobe Employee
November 10, 2010

A paragraph always ends a line, and the following text will be in a different line. I don't know of a way to get the effect you want, except for combining the two pieces of text into the same paragraph, or (if they are the complete text) putting them in two separate containers that are placed next to each other.

- robin

Adobe Employee
November 2, 2010

TLF terminates every paragraph with a "paragraph terminator" (Unicode 2029). This is so that we can use index offset from the start of the TextFlow, and have it work even with empty paragraphs.

However, this terminator does not cause a blank line between paragraphs, it simply ends the paragraph (and thus the line). I'm not sure what is causing your blank line. It could be a blank paragraph, between the two paragraphs. Or the first paragraph may have a paragraphSpaceAfter set, which would cause additional space to be added between it and the next paragraph. The next paragraph could have a paragraphSpaceBefore attribute set, with the same result.

One thing that might help in diagnosing the problem is if you could supply the XML for your TextFlow. You can do this by calling:

var xmlString:String = TextConverter.export(textFlow, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.STRING_TYPE);

xmlString will contain the xml for the flow.

How are you creating your TextFlow? Does it start empty and the user edits it, or does it come in as data stored off in TEXT_FIELD_HTML _FORMAT or PLAIN_TEXT_FORMAT? Or are you using something in Flex or Flash Authoring to initialize it?

How have you been doing your workaround to delete the return?

Thanks,

- robin