Nido Web Tutorials

ActionScript 2.0
ActionScript 3.0
Hello World - Pure Code

1. Create a - Flash File(ActionScript 3.0)

2. Now go to your Actions tab, you can do this by pressing F9, or going to Window - Actions in your menu bar.

3. In your "Actions - Frame" tab, type the code:

var textBox:TextField = new TextField();

var Declares you are making a variable.
textBox Name I chose for the box of text (or text object) we are dealing with.
TextField Says you are making a text field.
new TextField() Pretty much says you are making a new text field.


textBox.x = 10;

This line declares the X value location will be 10 units right of the left edge of the flash window.
The X value controls how far left or right something is. If X is 0, then the object will be on the
left side of the screen, and the higher the value, the further right it will be. For those who have
programmed in ActionScript 2.0, you may notice that it is just .x instead of ._x, which is no longer used.


textBox.y = 10;

Much of the same as the last line. If Y is 0, then the object will be placed at the top of the screen.
The higher the value of Y, the lower on the flash window the object will be.


textBox.width = 500;

This sets the width of the text box. If the width is too small, then the text will be cut off, and you
will not be able to see all of your text.


textBox.text = "Hello World";

This line of code will determine what will be said in your text box. The quotes (" or ') around the text are required.


textBox.type = TextFieldType.DYNAMIC;

This line says what type of text box it will be. There are 3 different types:

INPUT - This is a text box you can edit the text of. You can use this for users to enter numbers, names, or other text. This text is selectable.

DYNAMIC - This is a text box that can only be edited by code. You can use it to show a user's score, or other information that can change. This text is selectable.

Static - This is a type of text you can not create with code. You must use the graphic tools to create static text. This type of text is not selectable.

textBox is the name of our text object again.
type is a another attribute you can declare.
TextFieldType just says that you are declaring the type of text field it is going to be. (Yeah, I feel a lot of this language is pretty redundant at times...)
DYNAMIC is one of your choices what type of text box you have.



This adds the object to the display list. A list of objects that will be put on the screen when you run your SWF.

Hold Control and press Enter. This will render your SWF to show you what your results are.
You can also go to Control on your menu bar, then Test Movie to do the same thing.

Complete Code:
var textBox:TextField = new TextField();
textBox.x = 10;
textBox.y = 10;
textBox.width = 500;
textBox.text = "Hello World";
textBox.type = TextFieldType.DYNAMIC;

FLA File