Home Guess The Number Game
Guess The Number Game PDF Print E-mail
Written by Geoff Hill   
Thursday, 01 April 2010 09:22

Lesson 1:

In this lesson you will create a game that selects a random number between 1 and 100. The player will be prompted to guess the number. If they guess the correct number the game will tell them, pick a new random number and prompt them to play again. Otherwise the player will be given feedback and prompted to guess again.

JULY 2009: Source code updated for Actionscript 3.0
Download source code for AS3 GuessNumber.pdf

Learning Outcomes:

  • Use flash text boxes to display variables and collect input
  • Use variables to store and update data
  • Use built-in functions to pick a random number
  • Create a function to check user input against the random number
  • Attach the function to a button to enable game play

The Game Interface:

Game Interface

The game interface requires the three types of text available in flash: Static, Dynamic and Input. It also requires a button to collect and check the guess against the random number selected.

  • Static text is used for the labels of variables, and the button.
  • Dynamic text is used to put feedback messages on the screen and display the total number of guesses.
  • Input text is used to collect the number guessed by the player.

 

 
Copyright © 2012 geoffhill.com.au. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.