Skip to content
bustardcelly edited this page Sep 14, 2010 · 9 revisions

Label displays single and multiline textual content with optional autosizing and truncation.

By default, the Label control is a single-line non-autosizable display for textual content. As such, a single line of text is created and display within the defined width (defaulted to 100px).

Usage:

var label:Label = new Label();
label.text = "Hello World."
addChild( label );

There are two rendering contexts associated with the Label control that manages the textual display based on the autosize and multiline properties. These are:

TruncationLabelRenderer

[Default] By default, the Label control is a single-line, non-autosizable display. In such a state, Label uses TruncationLabelRenderer to determine the amount of supplied textual content can fit within the defined width of the control and adds truncation text if there is overflow. The default truncationText is a bread crumb (…) but can be changed.

MultilineLabelRenderer

With a label defined as mutiline, textual content is filled within the defined width and height.

Examples:

The following example uses the default single-line, non-autosize truncation rendering.

var label:Label = new Label();
label.text = "Pack my box with five dozen liquor jugs.";
label.width = 120;
label.truncationText = "... more";
addChild( label );

The following example uses mulit-line, non-autosize rendering.

var label:Label = new Label();
label.text = "Pack my box with five dozen liquor jugs.";
label.width = 30;
label.height = 120;
label.multiline = true;
addChild( label );

You can specify the autosize property on a Label as true, which will resize the visible area based on the textual content:

var label:Label = new Label();
label.text = "Pack my box with five dozen liquor jugs.";
label.width = 30;
label.multiline = true;
label.autosize = true;
addChild( label );

autosize can be set for both single and multi-line specifications.

Clone this wiki locally