Simple guess a number game in Flash
In this Macromedia Flash tutorial I will show you how to make a simple guessing a number game, which requriers only very basic skills to follow.
1.
Now the essential elements we need for this tutorial is a dynamic text field to write the result in, an input field to type in our guess, and a button to submit the guess.
So a just made an input text field and gave it an instance name of "Guess" the dynamic text field I called "Result_num".
And i made a simple graphic and converted it to a button.
2.
Now click once on the button, then go to the actionscript panel and type in the following code.
3.
on (release) {
var _num = random(10);
if (_root.Guess.text == _num) {
_root.Result_num.text = "You are right, you win"
} else {
_root.Result_num.text = "No sorry it was " + _num
}
}
-------------------------------------------------------
var _num = random(10);
Here we declare a variable to be a random number between 1 and 10
Then we make an if statement, that says if the guess text field is equal to the random number variable
then the result text field will say "You are right, you win" or else it will say _root.Result_num.text = "No sorry it was " followed by the correct number.
Now test your game, and you should have something like mine, you can now do something with the interface, because its the visual part that make it interesting for the user.