system
September 9, 2001, 3:14am
1
Is to possible to generate negative and positive random numbers in Flash? I know how to generate numbers from say 0 to 100 but what about generating random numbers from say… -100 to 100? I havent heard of this before but then again this is an unusual request.

Any help appreciated.

Chris

system
September 9, 2001, 3:33am
2
I don’t know if it’s directly possible… but certainly a work around could be produced.

negpos=random(2)
if negpos=0
neg=true
totalRandom=random(100)
totalRandom=TotalRandom+1
if neg=true
totalRandom=(totalRandom)*-1

bear with me if that example doesn’t work… I’m not much of a programer yet… none the less it should be something similar to that.

system
September 9, 2001, 4:53pm
3
Ok thanks. I got it to work.

Chris

system
September 9, 2001, 6:27pm
4
here’s a cleaner method:

num = Math.random()*200-100;

this makes num equal some number b/w -100 and 100.

system
September 11, 2001, 8:58am
5
really… Sweet…

See that’s what I love about flash… there are always a dozen ways of doing something…

Be forwarned… I only took algebra as my top level math… with math, I’m stumbling around in the dark.

Thanks again suprabeener