• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Lottery game using flash

I have been asked to create a lottery game in flash. Are there any dir files of completed flash games or anything that might help e.g. random number generater etc
0
lukegriffiths110
Asked:
lukegriffiths110
1 Solution
 
BillystyxCommented:
for random numbers you can use
myvar=random (1000);
this will come up with a number between 0 and 1000

It s a start
or you can use
Math.random() which gives you a number between 0 and 1

Billystyx
0
 
gmailrulesCommented:
good site with a lot of game tutorials:

http://www.gotoandplay.it/
0
 
vickerleungCommented:
lukegriffiths110

Is EE's rule not to do the thing for members

However I can still provide you with the idea behind

The most difficult part within a lottery is that duplicate record is not allowed (I guess your game too, right)

So I will suggest you make a single number generator function and an array to store up the generated number

The prototype will be something as below

_root.number_requires = 6;      // say you wanna draw six times
_root.number_maximum = 100;      // the maximum number that can be drawn
_root.current_number = 1;      // the current number you are drawing
_root.temp_number = 0;            // for storing the number that will be insert to array
_root.number_array = new Array ();
_root.duplicate_checker = new Boolean ();

_root.loop_num = 0;            // temporary loop number
_root.loop_num_2 = 0;

function draw_number ()
{
      _root.temp_number = random (_root.number_maximum) + 1;
      _root.duplicate_checker = FALSE;      
            
      if (_root.current_number != 1)
      {
            for (_root.loop_num = 0; _root.loop_num < _root.current_number - 1; _root.loop_num++)
            {
                  if (_root.temp_number == _root.number_array [_root.loop_num])
                  {
                        _root.duplicate_checker = TRUE;
                  }
            }
      }

      if (_root.duplicate_checker == FALSE)
      {
            _root.number_array [_root.current_number - 1] = _root.temp_number;
            _root.current_number++;
      }
      
      if (_root.current_number <= _root.number_requires)
      {
            draw_number (); // recursive call itself until all numbers drawn
      }
}

draw_number ();
trace (_root.number_array); // put the answer out

Vicker
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now