eHow launches Android app: Get the best of eHow on the go.

How To

How to Create a Random Pick 3 Number Generator

Member
By nmey
User-Submitted Article
(0 Ratings)
What your final product might look like
What your final product might look like
Neil Mey

From this tutorial you will learn how to animate and use action script 2.0 to create a simple random number generator flash program using Flash 8 or higher.

Difficulty: Challenging
Instructions

Things You'll Need:

  • Adobe Flash 8 or higher
  1. Step 1

    Open Flash and create a new flash document

  2. Step 2

    We do not need our application to be that big so we are going to reduce the window size by selecting Modify>Document. A new window should have popped up.

  3. Step 3

    in that new window change the dimension size to the following
    300 px (width) by 150 px (height)

  4. Step 4

    Once you have done this and with the window still open, go ahead and change the background color by clicking on the square. Pick any color you want. I chose blue.

  5. Step 5

    At this point we are going to create the simple ball graphic we need.
    First we will make the ball by selecting Insert>New Symbol
    Rename the symbol "ball" and make sure to select next to Type: Movie Clip. And then click ok.

  6. Step 6

    Make sure your tool pallet is up. If you do not see it select Window>Tools
    select the oval shape from the tools pallet or by pressing its shortcut key letter o.

  7. Step 7

    On the tool pallet ,under color, next to bucket fill icon, change the fill color to one of the gradients in the shape of a ball. I chose the grey one since it resembles the ones from the lottery broadcast on TV

  8. Step 8

    In the middle of the stage you will notice a crosshair. Put your mouse, which should also look like a crosshair in the middle of the crosshair on stage.

  9. Step 9

    Hold down the alt button and drag your mouse out and let go when the desired size image is made. By holding down alt it enabled you to make a perfectly round ball.

  10. Step 10

    Now the default gradient we used is not quite what we are looking for. Using your bucket tool by using shortcut key K click once on the top right part of the ball image. It should now look a little bit lighter

  11. Step 11

    We are now done with our image. To navigate back to our animation click on scene 1 next to timeline.

  12. Step 12

    Double click layer 1 and rename it ball_1. From your library drag your ball image to the stage. Place it on the stage remembering you will need room to eventually have 3 of these pick 3 balls on stage horizontally.

  13. Step 13

    Once on the stage make sure the ball is selected. On your properties bar select the filters tab.

  14. Step 14

    With the filters tab selected click on the plus sign (+). Add a drop shadow and a blur filter to it.

  15. Step 15

    Select blur from the list and put in the following information
    Blur X: 6 and Blur Y: 6

  16. Step 16

    In your timeline move to frame 7. Insert a keyframe by selecting Insert>Timeline>Keyframe

  17. Step 17

    Move to frame 1 in your timeline. Click on the ball and move it up so that it will look like the ball is dropping when we animate it.I placed it at the following location X: 24.5 Y: .5

  18. Step 18

    Move to Frame 8 and insert a keyframe. Move the ball up a little bit.
    X: 24.5 Y: 30.5

  19. Step 19

    With the ball still selected click the filters tab on properties bar and change the blur to 11 for X and Y values

  20. Step 20

    Move in your timeline to frame 9 and insert a keyframe. Move the ball back down a tad to X: 24.5 Y: 53.5

  21. Step 21

    Change the blur filter to 4 for the X and Y values

  22. Step 22

    In your timeline on frame 10 insert a keyframe. Its location should be
    X: 24.5 and Y: 43.5

  23. Step 23

    Select ball layer. Keyframes in timeline on this layer should be highlighted black. On your properties bar next to tween select motion from the dropdown.

  24. Step 24

    Create a new layer and rename it ball2. Repeat on this layer steps 15-26 and change the location of image as necessary

  25. Step 25

    Create a new layer and rename it ball3. Repeat on this layer steps 15-26 and change the location of image as necessary

  26. Step 26

    We now need to create dynamic text boxes so that numbers will show up on the ball images. So first create a new layer and place it above your ball1 animation layer renaming it number1.

  27. Step 27

    Move in your timeline to frame 10 and insert a blank keyframe.

  28. Step 28

    Making sure you are on frame 10 and on number1 layer, select text from the tools palette and create a textbox within the boundaries of your ball1 image that is on the stage

  29. Step 29

    Select the textbox you just created and on your properties bar change it to dynamic text from the dropdown list.

  30. Step 30

    n the properties bar next to var: type in numb1

  31. Step 31

    Repeat steps 29-33 for ball2 and ball 3 images. Change names and numbers appropriately.

  32. Step 32

    Now we need to create a button. Insert>New Symbol. A window should pop up. Rename it "Button" and next to type make sure button is selected.

  33. Step 33

    Make your button any shape and color you want. I made mine oval with a red gradient for up and down states and green gradient for over state.

  34. Step 34

    At this point we need text placed on the button. Using the text tool type "Pick3". Under properties make sure the text box is static text. If it is not select it from the dropdown list.

  35. Step 35

    Your button is now made so navigate back to scene1

  36. Step 36

    Create a new layer and rename it button

  37. Step 37

    From your library drag out the button you just made on to the stage.

  38. Step 38

    Now for the action scripting. Create a new layer and name it actions. Move the layer to the top of your layer list.

  39. Step 39

    At frame 10 of the actions layer insert a blank keyframe. Right click on the keyframe and select actions.

  40. Step 40

    With your actions window up type in the following random number script
    numb1 = random(10);
    numb2 = random(10);
    numb3 = random(10);
    value of ten is inserted because possible number choices are 0-9 for the pick3 and 0 is considered a number.

  41. Step 41

    Close out of the actions window

  42. Step 42

    On the stage select your button. Right click and select actions. Actions window should pop up.

  43. Step 43

    In the actions window make sure Script Assist is selected. Chose the following from the left hand panel. Global Functions>Timeline Control>goto.

  44. Step 44

    Select go to and play and change it to frame1. Close out the window

  45. Step 45

    Save your file

  46. Step 46

    49. To test your animation select: File>Publish Preview>Flash

    When you click on the button it should give you new lucky numbers. Hopefully winning ones.

Tips & Warnings
  • Change your numbers accordingly. The positions for your lotto balls may differ depending on the size you make the graphic.
  • Be creative with your graphics. At first you can make simple ones. After you get the code working you can always go back and switch out the graphics for better ones.
  • Using this code you do more than just pick 3 you could even do a powerball if you want
  • Shortcuts are given in regards to Mac operating system
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics