0
Paragraph spacing in Dynamic Text Field
Explorer
,
/t5/animate-discussions/paragraph-spacing-in-dynamic-text-field/td-p/14559
Mar 26, 2009
Mar 26, 2009
Copy link to clipboard
Copied
I have a dynamic text field that's being loaded with text
from an external xml file. The data can contain a carriage return
if entered by the user to force a line break.
All is working except that the textfield displays a gap equivalent to about two lines between the first and second line when the data contains a carriage return.
I can't seem to find a way to set the line height or paragraph height for the textField to make the line spacing tighter. Any suggestions?
All is working except that the textfield displays a gap equivalent to about two lines between the first and second line when the data contains a carriage return.
I can't seem to find a way to set the line height or paragraph height for the textField to make the line spacing tighter. Any suggestions?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/animate-discussions/paragraph-spacing-in-dynamic-text-field/m-p/14560#M22
Mar 29, 2009
Mar 29, 2009
Copy link to clipboard
Copied
it seams that flash treat your carriage return as a new
paragraph. You cant set line height or paragraph directly on the
TextField, instead you need to attach a style sheet, or a
TextFormat.
var aNumber = 4;
var myTextFormat = new TextFormat();
myTextFormat.leading = aNumber; (distance between lines)
yourTextField.defaultTextFormat = myTextFormat;
or better a style sheet
for more help with style sheets just consult the adobe documentation.
var aNumber = 4;
var myTextFormat = new TextFormat();
myTextFormat.leading = aNumber; (distance between lines)
yourTextField.defaultTextFormat = myTextFormat;
or better a style sheet
for more help with style sheets just consult the adobe documentation.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/paragraph-spacing-in-dynamic-text-field/m-p/14561#M23
Mar 29, 2009
Mar 29, 2009
Copy link to clipboard
Copied
You can try "leading" property of TextFormat or "leading"
prperty of StyleSheet.
Also, you may want to remove carriage returns and such (or replacing them with entities of your liking such as <br>) before you place text into the TextField via RegEx:
var regexPattern:RegExp = /\n|\r/g;
var str:String = "one line\nano\rther line \nthird \nline.";
trace(str.replace(regexPattern, ""));
or
trace(str.replace(regexPattern, "<br>"));
Also, you may want to remove carriage returns and such (or replacing them with entities of your liking such as <br>) before you place text into the TextField via RegEx:
var regexPattern:RegExp = /\n|\r/g;
var str:String = "one line\nano\rther line \nthird \nline.";
trace(str.replace(regexPattern, ""));
or
trace(str.replace(regexPattern, "<br>"));
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
srauh
AUTHOR
Explorer
,
LATEST
/t5/animate-discussions/paragraph-spacing-in-dynamic-text-field/m-p/14562#M24
Mar 30, 2009
Mar 30, 2009
Copy link to clipboard
Copied
I tried adding a leading value on the textField. I didn't
think to try it with a textFormat.
My solution was to create a function to filter the input text. The function splits the input string using [\r\n] as the delimiter pattern. Then it wraps each string in the resulting array with <p> and </p> and returns.
Instead of adding the string to textField.text it's added to textField.htmlText. This solution seems to work.
I may experiment with the leading property more when I have a chance.
Thanks for the input.
My solution was to create a function to filter the input text. The function splits the input string using [\r\n] as the delimiter pattern. Then it wraps each string in the resulting array with <p> and </p> and returns.
Instead of adding the string to textField.text it's added to textField.htmlText. This solution seems to work.
I may experiment with the leading property more when I have a chance.
Thanks for the input.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

