|
-
XRave
A bitter Actionscript - [Help]
I have a "program" here that automatically generate 3 numbers between -100 to 100 (%) so that it's completely random. But I have no idea how to make the Random action start dealing with Variables. Any ideas for it? A simple code would help.
Regards,
And hope you had a Merry Christmas
Tongxn
P.S. I keep getting into trouble...
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
I need more information on what your trying to do.
-
I dont know what you are trying to do but I hope this helps:
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.random()*(max-min)+min;
return randomNum;
}
no1 = randRange(100, 100);
no2 = randRange(100, 100);
no3 = randRange(100, 100);
-
XRave
just a randomical number chooser.
I am not asking to much am I?
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Senior Member
 Originally Posted by tongxn
I have a "program" here that automatically generate 3 numbers between -100 to 100 (%)
So do you have a program that does this or are you looking for help building a program that does this? If you want to build this, then Chaos_Blader's post should help.
Otherwise
 Originally Posted by tongxn
just a randomical number chooser.
I am not asking to much am I?
code: myNum = Math.random();
will give you a random number.
_t
-
Code:
myNum = Math.random();
will give you a random number between 0 and 1... you need to multiply it by a scale
Code:
myNum = Math.random() * 100;
will give you a number between 0 and 100;
If you can read this, you're in the right place.
-
XRave
and what is to it a number between -100 and 100?
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Senior Member
Between -100 and 100????
See Chaos_Blader's post. You already have the answer!
Except add a negative sign in front of the first 100.
_t
-
If you want to make a random number between -100 and 100 maybe you can fix it with this
myNum1 = Math.random() * 100;
myNum2 = Math.random() * 100;
myNum = myNum1-myNum2;
Then you will get a a number between -100 and 100
But the chance that then number is -100, 0 or 100 is very small. (But possible)
I hope this helped you a little bit.
-
Code:
var myNum = random() * 200 - 100;
Will get you a number between -100 and 100, but Chaos_Blader had it right, execpt the examples he forgot to put a minus sign in the no1, no2, and no3 examples.
 Originally Posted by Chaos_Blader
Code:
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.random()*(max-min)+min;
return randomNum;
}
no1 = randRange(-100, 100);
no2 = randRange(-100, 100);
no3 = randRange(-100, 100);
If you can read this, you're in the right place.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|