One of the cool tools you can use in Flash is input text—that is, text that
is input by the user as the program is running. This information is stored
as one or more variables that can be accessed later by the program and used
in a variety of ways. In this simple exercise, you will create a swf file that
asks for the user's name, then displays it in a greeting.
Specifications
Size: 550 x 400 (default Flash size)
Frame Rate: 12 fps (default)
Length: 2 frames
Due Date: week 6 (11/13)
Deliverables: both the FLA and exported SWF files.
Procedure
Open a new Flash document.
Draw a text box; choose static text. In the text box, write "What
is your name?" You can choose whichever font face, color & size you prefer.
Below the static text box draw another text box. Change this one to input
text. Give it the variable ("var") name inputText. Note that this variable name is arbitrary; I could have called it just about anything, even fred, but inputText is more descriptive.
Put a button on the page (make a shape, convert it to a button symbol).
On the button, add the following action:
on (release) {
gotoAndStop(2);
}
Create a new layer for actions. Click on the keyframe in this new layer
and open the actions window. Add a stop();
Add blank keyframes to both layers in frame 2.
In the non-actions layer, add a new text box. Make this one a dynamic text
field. Give it the variable name outputText.
Set the font face, color and size to your preference.
Put a button on this page (you could use the same one). On the button put:
on (release) {
gotoAndStop(1);
}
In the actions layer in frame 2, add the following script:
stop();
outputText = "Hello there, "+inputText+"!"
Try it out.
Important: When you use either input or dynamic text fields in a Flash movie, you should embed the font you specified for use in those fields. To do this, click on the field(s), and press the "embed" button. Choose whichever character sets you think you'll need (usually upper case, lower case, numbers, punctuation & basic Latin).
Export a .swf. Turn-in both .swf and .fla files.
Go Above and Beyond
Some possibilities:
Add more text fields.
Create a cool looking interface and buttons.
Find a use for input/output text. One possibility is a "Mad Lib;" here's a link to a one such exercise I sometimes give to more advanced classes.
Point Breakdown
10 pts
Went above & beyond and made something special
9 pts
Above and beyond the basics.
8 pts
Did the basics; it works, but it's nothing fancy.
7 pts
Something's not working right.
0-6 pts
Poor showing; mostly incomplete or full of errors.