Skip to content

Instantly share code, notes, and snippets.

@jasonmelgoza
Created October 9, 2009 18:30
Show Gist options
  • Save jasonmelgoza/206229 to your computer and use it in GitHub Desktop.
Save jasonmelgoza/206229 to your computer and use it in GitHub Desktop.
//Creating the textfield object and naming it "myTextField"
var myTextField:TextField = new TextField();
//Here we add the new textfield instance to the stage with addchild()
addChild(myTextField);
//Here we define some properties for our text field, starting with giving it some text to contain.
//A width, x and y coordinates.
myTextField.text = "some text here!";
myTextField.width = 250;
myTextField.x = 25;
myTextField.y = 25;
//Here are some great properties to define, first one is to make sure the text is not selectable, then adding a border.
myTextField.selectable = false;
myTextField.border = true;
//This last property for our textfield is to make it autosize with the text, aligning to the left.
myTextField.autoSize = TextFieldAutoSize.LEFT;
//This is the section for our text styling, first we create a TextFormat instance naming it myFormat
var myFormat:TextFormat = new TextFormat();
//Giving the format a hex decimal color code
myFormat.color = 0xAA0000;
//Adding some bigger text size
myFormat.size = 24;
//Last text style is to make it italic.
myFormat.italic = true;
//Now the most important thing for the textformat, we need to add it to the myTextField with setTextFormat.
myTextField.setTextFormat(myFormat);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment