The Magic 8Ball

I just learned how to use variables and generate random numbers so I create a classic Magic 8ball

I hope you like it


Awesome! Would you mind sharing how you did that? Did you have to use javascript to access the variables?

Yeap, I used the javascript for the variables. As you can see, the answers are just variables, and to start the variable “answer” is an empty text

window.answer.innerHTML = '';

And then for the options I generate a random number from 1 to 20 and depending on the number I assign an answer like…

window.mensaje.innerHTML = 'My reply is no';

Is this helpful or you need something specific ?

1 Like

I am very new to CSS, HTML, Javascript, and HYPE. I have done a little coding in C# but I am primarily an artist. I was hoping to see how everything worked together on a seemingly fun but simple scene. I understand if you don’t want to share your project file but maybe you know of a tutorial you would recommend. Thank you!

This Forum is to help and learn, at least for me (LOL), I don’t mind to share the hole project.

As you can see I love simple things, I like one button games and thats what I do, I did games with flash AS2 for 20 years and is time for me to change platform, but with the same rules, one button

Check my flash and HTML5 site, I love the feedback

And here is my MAGIC 8 BALL project

I got rid of the Google stats and ads (those pay my time) and I apologize for the comments, all the comments are in spanish, but I can tell you that the main random function is on the HTML header and I just call that function inside the game.

Min & max in that function are for the numbers I generate (0 to 19) and I add 1 to have (1 to 20)

Function “aleatorio” is spanish word for Random

Everything else is self explanatory on the project. Is a button that triggers an animation that shakes the ball and call a function for a random number and based on the number take the answer related to the number and displays it.

I hope it helps!


I clicked on the link for the project file and get a 404 Not Found error.

“The requested URL / was not found on this server.”

Link not correct perhaps?

My mistake, Is been corrected

Sorry everyone. :woozy_face:

1 Like

Thank you very much for this! This helps a lot. I can use google translate to understand the comments. It’s great!

I love your site. Some of the old games didn’t work on my computer. The movies did not work on the new site for me either, unfortunately. I like the idea of a one click game/movie site. I did notice some grammatical/usage errors; I take it you’re not a native English speaker due to the coding comments and whatnot. I’d love to help localize. On the opening page, I’m seeing “Flash is” as one word ‘Flashis’ it should be two words. Also ‘Click Anywhere’ is the common phrase not ‘Click Everywhere’. Let me know if you’d like more of that stuff. And thank you again!

1 Like

Thanks for the kind comments and the help!

I’ll check everything :relaxed: