User Guide
Customizing the Label component 753
Creating an application with the Label component
The following procedure explains how to add a Label component to an application while
authoring. In this example, the label is beside a combo box with dates in a shopping
cart application.
To create an application with the Label component:
1. Drag a Label component from the Components panel to the Stage.
2. In the Component inspector, enter Expiration Date for the label parameter.
To create a Label component instance using ActionScript:
1. Drag the Label component from the Components panel to the current document’s library.
This adds the component to the library, but doesn’t make it visible in the application.
2. Select the first frame in the main Timeline, open the Actions panel, and enter the
following code:
this.createClassObject(mx.controls.Label, "my_label", 1);
my_label.text = "Hello World";
This script uses the method UIObject.createClassObject() to create the
Label instance.
3. Select Control > Test Movie.
Customizing the Label component
You can transform a Label component horizontally and vertically while authoring and at
runtime. While authoring, select the component on the Stage and use the Free Transform tool
or any of the Modify > Transform commands. You can also set the autoSize authoring
parameter; setting this parameter doesn’t change the bounding box in the live preview, but the
label is resized. For more information, see “Label parameters” on page 752. At runtime, use
the
setSize() method (see UIObject.setSize()) or Label.autoSize).
Using styles with the Label component
You can set style properties to change the appearance of a label instance. All text in a Label
component instance must share the same style. For example, you can’t set the
color style to
"blue" for one word in a label and to "red" for the second word in the same label.
If the name of a style property ends in “Color”, it is a color style property and behaves
differently than noncolor style properties. For more information about styles, see “Using styles
to customize component color and text” in Using Components.