Flash CS3 Documentation |
|||
| Programming ActionScript 3.0 > Working with text > Displaying text > Modifying the text field contents | |||
You can define dynamic text by assigning a string to the flash.text.TextField.text property. You assign a string directly to the property, as follows:
myTextField.text = "Hello World";
You can also assign the text property a value from a variable defined in your script, as in the following example:
package
{
import flash.display.Sprite;
import flash.text.*;
public class TextWithImage extends Sprite
{
private var myTextBox:TextField = new TextField();
private var myText:String = "Hello World";
public function TextWithImage()
{
addChild(myTextBox);
myTextBox.text = myText;
}
}
}
Alternatively, you can assign the text property a value from a remote variable. You have three options for loading text values from remote sources:
FlashVars attribute is embedded in the HTML page hosting the SWF file and can contain values for text variables.Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000222.html