Create New TextField with Flash ActionScript 3
This is the second series of Flash ActionScript 3 tutorials. We will also use ActionScript to print out the "Hello World" texts on the stage of Flash movie.
Flash Tutorial Content:
In the first serial of Flash tutorial, we used Flash ActionScript printed out the "Hello World" to the Text Field on the stage of flash movie. The Text Field was drawn by us. This would be wonderful if we can also use Flash ActionScript to draw the Text Field as well!
In this tutorial, we are going to use Flash ActionScript to create (draw) a new TextField. And then we will use Flash ActionScript to print out the text "Hello World" to the newly created Text Field.
Flash ActionScript Codes:
///// Create New TextField /////
// Create a textfield object with the name "textField_txt"
var textField_txt:TextField = new TextField();
// Add the new textfield_txt instance to the stage
// Add Content to TextField
textField_txt.text = "Hello World";
Download Flash Source File:
Hey... The Text Field print out on the Top Left corner of the stage. Why? This is because the new Text Field will be created at the Top Left corner (co-ordinate 0,0) by default. In the next tutorial, we will set some properties (e.g. position, size, etc..) to the new Text Field.