Introduction
I hope this havent been done before but this tutorial is to learn you to make Dynamic Text Boxes using nothing but ActionScript.
Making The Text Box
First create a new Flash Document.
Press F9 to get to the Actions box.
Here type this code to make a text box:
_root.createTextField("t", 1, 100, 100, 88, 18);
What it does is that it makes a new Dynamic Text Box with a variable name of "t".
The text box is placed x=100 and y=100 and is width=88 and height=18.
Setting The Text Box' Properties
We got our Dynaimc Text Box called "t" and now we're gonna set its properties.
Start with place this piece of AS below the AS where we created the Text Box:
with(t){
}
This is where we will place the properties-codes.
The most important porperty-code is this:
text="hello";
This is what the text will be. Of course you can change "hello" to any text you want inside the text box.
Other Usefull Properties:
_alpha
The transparency value of a text field instance.
background
Indicates if the text field has a background fill.
backgroundColor
Indicates the color of the background fill.
border
Indicates if the text field has a border.
borderColor
Indicates the color of the border.
maxChars
The maximum number of characters that a text field can contain.
password
Indicates if a text field hides the input characters.
restrict
The set of characters that a user can enter into a text field.
textColor
The color of the current text in the text field.
type
Indicates whether a text field is an input text field or dynamic text field.
_visible
A Boolean value that determines whether a text field instance is hidden or visible.
_xmouse
The x coordinate of the cursor.
_ymouse
The y coordinate of the cursor.
Examples:
_root.createTextField("t", 1, 100, 100, 88, 18);
// Creates a new text box
onEnterFrame = function () {
// Using onClipEvent(enterFrame) so it will update the amount
_root.t.text = _xmouse+", "+_ymouse;
// Making so the text box will show where the mouse are
};
----------
Makes a text box where it shows wherever the mouse are
----------
_root.score=0;
// Making the variable "score" with a value of 0
_root.createTextField("t", 1, 100, 100, 160, 18);
// Creates the text box
with (t) {
// The text box' properties
textColor = 0xFF0000;
// Making the text red, not necesarry
}
onEnterFrame = function () {
// Using onClipEvent(enterFrame)
_root.t.text = "Score: "+_root.score;
// Making the text box show Score: 0
};
-------------
Making a text box with the text Score: 0
Can be used for games with score
-------------
//guywithhiscomp
(im from sweden so it may be a little misspelling in the text)
