Free Flash Tutorials

Home • Members Tutorials Forum iSnapChat Contact Us 


Flash Tutorials

Flash 5 - Simple Word Game

Intermediate Flash 5
Flash Compatibility: 5    
For Flash MX click here
Written by: Phil


My Example 1: Download the Flash file  Int 159a - Flash 5


Click play and try typing: hen, chicken, rooster, cockerel and also a misspelling.


For a Flash MX tutorial: click here

In this tutorial I am not going to go through every detail of how the movie is made but instead just look at the action script and text input box, which is what makes the movie work. For details of how the movie is structured download the movie, almost everything is visible in the time line in scene two.
You can access this by clicking on the scene button: and selecting game.

Step one: Text Input Box

You will find this in scene 2 (game) in the layer 'text' and the frame with the label 'blank'.

The frame is labeled blank because the text input box is always empty or blank at this stage.

  1. To create the text input box first open the text options panel. You will find this under Window > Panels> Text Options.
  2. Select the text tool: and drag a box on stage.
  3. Select Input Text from the Text Option panel.
  4. Type a variable name. I used the name: answer. It does not matter what the name is, as long as it has a name.
  5. Select: Embed Fonts > Lower Case from the Text Option panel. If you do not restrict the case to either capitals or lower case you will find that what somebody types is case sensitive so if they type Rooster (instead of rooster) the answer is incorrect.

Your text options should look similar to this.

Step Two: Making the Text Input Box Blank

You do this so that when you come back to this frame the text field is empty.

  1. Place the following action in the time line: answer = new Array();
    If your text input box is not called answer type the name that you used instead of 'answer'.

Step Three: Placing the action script in the button

on (release, keyPress "<Enter>") {
    if (answer eq "rooster" or answer eq "cockerel") { 
        gotoAndPlay ("win");
    } else if (answer eq "hen" or answer eq "chicken") {
        gotoAndStop ("boy");
    } else {
        gotoAndStop ("wrong");

Line 1: on (release, keyPress "<Enter>") {
On the mouse click or if you press Enter on the keyboard and ...

Line 2: if (answer eq "rooster" or answer eq "cockerel") {
If the text input box called answer is rooster or cockerel then ...

Line 3: gotoAndPlay ("win");
Go to the frame labeled win.

Line 4: } else if (answer eq "hen" or answer eq "chicken) {
If the text input box called answer is hen or chicken then ...

Line 5: gotoAndStop ("boy");
Go to the frame labeled boy.

Line 6: } else {
This has not got a (answer = "word") which means that whatever is typed (other than the specified words above) then ...

Line 7: gotoAndStop ("wrong");
Go to the frame labeled wrong

Note: If you have specified lower case as the input text value then the words "rooster", "chicken" etc. must be typed here in lower case and visa versa if you have typed them in upper case.


Step Four: Creating the additional frames


You must of course create the frames which the buttons go to. These frames should have buttons or a timer which bring you back to this frame so that the user can try again.



Please indicate what you thought of this tutorial 
10 is the best: 
10 9 8 7 6 5 4 3 2 1

30647 visitors to this page since Jan 04

Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.