TextFormat.leading Property | Flash 6 |
specifies line spacing | read/write |
The integer leading property specifies the amount of vertical space between lines of text. It applies to paragraphs, which are spans of text separated by line break characters specified in code (\n, <BR>, or newline). When leading is 0, the font's metrics determine the line spacing. When leading is any positive integer, it specifies the extra space to add between lines, in pixels. Negative values for leading cannot be set via ActionScript but can be set during authoring with the Properties inspector for text.
To set the leading for an entire text field, invoke TextField.setTextFormat( ) without specifying any index arguments:
this.createTextField("theField_txt", 1, 0, 0, 50, 60); theField_txt.border = true; theField_txt.text = "This is paragraph one.\nThis is paragraph two." theField_txt.wordWrap = true; // Create a TextFormat object format = new TextFormat(); format.leading = 5; // Apply leading to the whole field theField_txt.setTextFormat(format);
To set the leading for the first paragraph in a text field, apply the format to the character at index 0:
theField_txt.setTextFormat(0, format);
To set the leading for any subsequent paragraphs, apply the format to the character immediately following the newline character:
theField_txt.setTextFormat(23, format);
To set the leading for a range of paragraphs, apply the format using start and end index arguments that include the desired paragraphs:
theField_txt.setTextFormat(0, 24, format);
If any paragraph wraps to the next line, the specified format range must include the subsequent line's first character; otherwise, the format will not apply to the wrapped line.
The default leading value (as contained in the TextFormat object returned by TextField.getTextFormat( )) for a text field that contains text is 0. For a text field without any text, the leading value is null. For a completely new TextFormat object, it is also null, indicating that leading will not be set when the format is applied to a text field:
trace(anyUnformattedField_txt.getTextFormat().leading); // Displays: 0 var format = new TextFormat(); trace(format.leading); // Displays: "null"