
TextFormat.leftMargin Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
899
TextFormat.leftMargin Property
specifies the margin to the left of a paragraph
Flash 6
read/write
theFormat.leftMargin
Description
The integer leftMargin property specifies the horizontal distance between the left border of
a text field and the left edge of a paragraph, in pixels. Negative values for
leftMargin are
converted to 0 by ActionScript. Note that regardless of the value of
leftMargin, Flash auto-
matically adds a small gutter between text and a text field’s border. There is no way to
align text perfectly flush with the border of a text field. The
leftMargin and rightMargin
properties can be used simultaneously on the same paragraph.
To set the left margin for an entire text field, invoke TextField.setTextFormat() without
specifying any index arguments:
this.createTextField("theField_txt", 1, 0, 0, 200, 40);
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.leftMargin = 10;
// Apply a 10-pixel left margin to the whole field
theField_txt.setTextFormat(format);
To set the left margin for the first paragraph in a text field, apply the format to the char-
acter at index 0:
theField_txt.setTextFormat(0, ...