Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > UIObject class > UIObject.createLabel() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
createLabel(name, depth, text)
name A string for the instance name.
depth A number indicating the depth of the new instance.
text The text for the label.
A TextField object.
Method; creates a TextField subobject. Used by most components to get a lightweight text object to display text in the component while inheriting sizing and style methods and properties of the component. This method is used to create new components. The TextField that is created is the same as a TextField object created using MovieClip.createTextField(), but has the added benefit of inheriting useful properties and methods from the parent UIObject.
A TextField that uses UIObject.createLabel() to create within a component can take advantage of the following inherited UIObject methods to set sizing and styles within the context of the parent UIObject:
|
NOTE |
|
TextFields created with |
For more information, see the MultilineCell.as file example in Simple cell renderer example.
The following example creates a TextField instance called multiLineLabel within a component's UIComponent.createChildren() method:
public function createChildren():Void {
var myTextField_txt:TextField = this.createLabel("multiLineLabel", 900, "Hello World");
// Set the fontSize style attribute of the TextField.
myTextField_txt.setStyle("fontSize", 18);
// Set the TextField's initial size.
myTextField_txt.setSize(myTextField_txt.getPreferredWidth(), myTextField_txt.getPreferredHeight());
// Set the TextField's initial location in the center of the Stage.
myTextField_txt._x = (Stage.width/2) - (myTextField_txt._width/2);
myTextField_txt._y = (Stage.height/2) - (myTextField_txt._height/2);
}
Flash CS3