|
||||||
|
||||||
159 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.
and drag a box on stage.
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.
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.
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
25647 visitors to this page since Jan 04 |
|
|
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.
|