Flash Tutorial - ActionScript 3.0 Textfield Code sample
Here is an ActionScript 3.0 code sample to to add a TextField. To start you will need to create a linkage to the desired font in the Flash IDE library. In this case the font I chose was Arial.
package
{
import flash.display.Sprite;
import flash.text.Textfield;
import flash.text.TextFormat;
public class TextfieldExample extends Sprite
{
private var myTextfield:TextField;
public function TextfieldExample(myString:String)
{
myTextfield = addTextfield(myString);
this.addChild(myTextfield);
}
private function addTextfield(myText:String):TextField
{
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.size = 11;
myTextFormat.color = "0x000000";
var myTextField:TextField = new TextField();
myTextField.selectable = false;
myTextField.mouseEnabled = false;
myTextField.embedFonts = true;
myTextField.autoSize = "left";
myTextField.wordWrap = false;
myTextField.multiline = false;
myTextField.defaultTextFormat = myTextFormat;
return myTextField;
}
}
}