;

PDA

Click to See Complete Forum and Search --> : Magic 8 Ball - what do you think?


cirrus97
01-13-2002, 04:45 PM
Hi, I was just fooling around with koolmoves and decided to see if I could make a "magic 8 ball".

Just wanted to see what you think about it. This was my first attempt at action scripting, and I think it works ok.

here it is:
http://pages.prodigy.net/cirrus97/swf/8ball.html

there is also a link at the bottom of the page to download the zip file that has the .fun file and the graphics I used.

Koolmoves and the help I found here really made this easy!
Thanks everyone for the help in your posts.

Ed

fwhilton
01-13-2002, 07:58 PM
Very clever...

Random action Script... Right?

johnie
01-14-2002, 12:13 AM
I like it.

Very nice.

I'm working on a Missle command game if I get time to finish it, I'll post it.
It would be nice if we could have the deprciated Flash 4 Random(X); action, which returns a random number between 0-X instead of fiddling around with the math.random() function which only returns a random number between 0-1.

Although I noticed that you used Math.floor(Math.random()*20)+1

I haven't played twith Math.floor yet, what does it do exactly.

bereft_m
01-14-2002, 04:51 PM
Math.floor(x)
floor() method returns the number x rounded up to an integer less than or equal to x
txt1=Math.floor(3.4); // will return 3

txt1=Math.floor(-3.4); //will return -4

johnie
01-14-2002, 06:40 PM
I got it figured out;

This will return a random value between n1 and n2:

Math.round(Math.random()*(n2-n1))+ Math.round(n1);

and this will return a value between 0 and the value

Math.round(Math.random()*(Value))

I have always used Math.round to get whole intergers instead of Math.floor but either way seems to work.

bereft_m
01-14-2002, 08:37 PM
When Math.Round converts a floating point number to the nearest integer, the answer will depend on the fractional value of the number. Postive number with fractional portion less that .5 and negative number with fractional portion greater than .5 are rounded down whereas postive number with fractional portion greater that .5 and negative number with fractional portion less than .5 are rounded up.

Math.round(1.4) will give you 1 but Math.round(1.5) will give you 2

In Math.floor the fractional value does not make a difference
Both Math.floor(1.4) and Math.floor(1.5) will return 1

In this case it does not make a difference though -- just a matter of technicality. :)

gonedigital
01-31-2002, 12:58 AM
Can we post your 8 ball on koolface? very nice work.

cirrus97
02-01-2002, 02:24 AM
Of course you can...
thanks for the kind words :)
Ed

---------------------------------------------------

Originally posted by gonedigital
Can we post your 8 ball on koolface? very nice work.