Label control

The Label control displays noneditable text. It is the lightest weight of the text controls. The Label control has the following characteristics:

  • The user cannot change the text, but the application can modify it.

  • You can control the alignment and sizing.

  • The control’s background is transparent, so the background of the component’s container shows through.

  • The control has no borders, so the label appears as text written directly on its background.

  • The control cannot take the focus.

  • The control can display multiple lines.

  • The control cannot be made selectable.

For complete reference information, see the ActionScript 3.0 Reference for the Adobe Flash Platform.

To create user-editable text fields, use the TextInput or TextArea controls. For more information, see TextInput control and TextArea control.

Creating a Label control

You define a Label control in MXML by using the <s:Label> tag, as the following example shows. Specify an id value if you intend to refer to a component elsewhere in your MXML, either in another tag or an ActionScript block.
<?xml version="1.0"?>
<!-- sparktextcontrols/SparkLabelControl.mxml -->
    width="150" height="80">

  <s:Label text="Label1"/>


The executing SWF file for the previous example is shown below:

Sizing a Label control

If you do not specify a width, the Label control automatically resizes when you change the value of the text property.

If you explicitly size a Label control so that it is not large enough to accommodate its text, the text is truncated and terminated by an ellipsis (...). The full text displays as a tooltip when you move the mouse over the Label control. If you also set a tooltip by using the tooltip property, the tooltip is displayed rather than the text.