To change the text of a Label instance, set either the text or htmlText properties. Similar to working with text fields, setting the text property sets the plain-text , and setting the htmlText property sets the HTML formatted text displayed by the Label. For more information on HTML formatted labels, see “Creating an HTML-enabled label instance in Flash using ActionScript 3.0″.
Note: If you are displaying large amounts of text using a Label instance, you’ll need to either set the width and height properties manually to accommodate the text, or use the autoSize and wordWrap properties to have the label auto-size to match the displayed text. For more information on automatically resizing labels, see “Automatically resizing a Label instance in Flash using ActionScript 3.0″ and “Creating a multi-line Label instance in Flash using ActionScript 3.0″.
The following example creates a Label instance with a large amount of text, and sets the width property to 240 pixels:
Full code after the jump.
// ActionScript 3.0 import fl.controls.Label; var myLabel:Label = new Label(); myLabel.text = "The quick brown fox jumped over the lazy dog"; myLabel.width = 240; myLabel.move(10, 10); addChild(myLabel);
For more information on the Flash/ActionScript 3.0 Label component, see the “Using the Label component” Flash Quick Start on Adobe.com.
{ 0 comments… add one now }