How to make space between text paragraphs?

10 posts

Flag Post

Hi.

A single TextField should be formatted to display some text paragraphs. There should be extra spaces between each paragraph but not between the text lines inside the paragraphs.

It should look like this:

I have tried:
- Leading. Yields spaces between ALL text lines, not only between paragraphs.
- HTML ‘p’ tag. No change.
- HTML ‘font’ tag with large ‘size’ style and a space character. Some weird results.
- HTML ‘span’ tag with a single large-fonted space. Same as above.
- ‘margin-top’ style. No result as it is not supported.

How should I do it?

Thank you.

 
Flag Post

You can use \n for a new line in your text:

output.text=“This is a paragraph. This is in the same paragraph.\n\nThis is a new paragraph.”

 
Flag Post

The text is going to be marked and copy-pasted by users to somewhere. This way the paste will include extra line breaks, which is not good.

 
Flag Post

Then you’re screwed.
The only thing you can do is use \n and then strip it in the area where it’s pasted.

 
Flag Post

CSS I think. I believe I solved the problem in some work I’m doing (contract, so I can’t show it), but I don’t know remember how exactly.

EDIT:
It works without my css, so maybe not.
It works without <textformat> tags, so not that either maybe

 
Flag Post

You could maybe use TLF instead of regular TextFields. I’m guessing they’d have this functionality, but I’m not certain.

 
Flag Post

http://www.fastswf.com/uc-AWDc

class SS extends StyleSheet{
		
		public function SS():void{
			setStyle(".empty",{leading:25}); // set to whatever you want.
			setStyle("p",{fontSize:25}); // same
		}
	}
...
...
t.styleSheet=new SS();
...
...
const P:String="<span class=\"empty\"><br/></span></p>";
t.text="<p>Some long text blablabala more text blablablalba bllab alb balbl a</p>"+P+
"<p>Another paragraph. blaba blb ab abl ablbabl abl abl</p>";
 
Flag Post

I’ll point out that that contains an extra carriage return that the OP doesn’t want.

const P:String="<span class=\"empty\"><br/></span></p>"; <— right there

I shall also note that it contains an extra </p>

 
Flag Post

Yeah, the extra </p> was a mistake when typing the code here. Should be ... balbl a"+P+
About the <br/>, that’s required for what the OP wants.

The copy/pasted text would be:
Some long text blablabala more text blablablalba bllab alb balbl aEOL
EOL
Another paragraph. blaba blb ab abl ablbabl abl ablEOL

Either by manual c/p or with System.setClipboard; that’s irrelevant. Which is paragraph → space → paragraph, which seems to me like what the OP is asking for.

If he wants to get a single paragraph in each line with no space between them, as in:
Some long text blablabala more text blablablalba bllab alb balbl aEOL
Another paragraph. blaba blb ab abl ablbabl abl ablEOL

It would be a matter of replacing duplicated EOL followed by an alphabetical character for a single EOL and the character, or using your suggestion if he doesn’t need to have control over the exact ammount of pixels between each paragraph.

Another option seems to be some RichEditableText thing which allows you to set space before and after a paragraph, but I don’t have that file nor feel like getting it only to test this. And it says that it uses special objects to display its elements.
Instead of going through that mess, he could as well use a different field for each paragraph.

 
Flag Post

So no easy way…

OK, I believe I can handle it by using TLFTextField but I cannot get it to work. TLFTextField doesn’t seem to exist inside the FlexSDK as my IDE (FDT that is) cannot resolve it and cannot import it. UNLESS I add TLFTextField into my Assets.fla library and compile it to .swc file. Now I can import it and use in my code.

All well but Flash IDE yields a warning while compiling .swc file:
Warning: No libraries were linked as Runtime Shared Libraries (RSLs) because of your publish settings: Export SWC

and .swc file grows by almost 500KB. How should I use TLFTextField the correct way?

EDIT: And the final .swf file grows by 200KB