In a previous example, “Changing the Label instance’s text in Flash using ActionScript 3.0″, we saw how to set a the text in Label control by setting the text property.
When using the Label component, you aren’t limited to plain-text formatting. By setting the label instance’s htmlText property, you can apply rich, HTML formatting such as bold, italic, underlined or linked text.
The following example displays an HTML formatted string in a Label component instance.
Full code after the jump.
// ActionScript 3.0 // Import the required component classes. import fl.controls.Label; /* Create a new Label component instance, set the htmlText property, and add the label to the display list. */ var myLabel:Label = new Label(); myLabel.htmlText = "The <b>quick brown fox jumped</b> over the <i>lazy dog</i>"; myLabel.wordWrap = true; myLabel.autoSize = TextFieldAutoSize.LEFT; myLabel.width = 150; 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 }