|
||||||
|
||||||
Flash - Word 159 Game
Free Flash Tutorial
The aim of the tutorial is to learn how to create a simple word game. You will create an input box which will give different results depending on what is typed. The code for this is quite straight forward and has many uses other than this word game. For example forms and password controls.
My
Example 1: Download the Flash file Int
159a
Click play and try typing: hen, chicken, rooster, cockerel and also a misspelling.
Step One: Text Input Box

Step Two: Making the Text Input Box Blank
You do this so that when you play the game the text field is always empty. For example if you get the wrong answer and try again the text field will reset to a blank box.
Step Three: Placing the ActionScript in the button
my button
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 in the code as lower case and visa versa if you have typed them
in upper
case.
Step Four: Creating the additional frames
You must create
the frames which the buttons go to. These frames should have buttons which
bring you back to play area of the game so that the user can try again.
Note the labels in the timeline
You create a frame label by selecting the frame and typing the name into
the Property Inspector.

The label 'wrong' has been typed into the Property Inspector
Your word game should soon be working a treat.
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
|
|
|
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.
|