-
[CS3] Random Numbers (help!)
I have 5 variables. I want each variable to be a different number 1-5 onClipEvent(load){. How can I do this? I tried using a big If((not…){ }else{
code and var nums = [1, 2, 3, 4, 5];
for (var i in nums) {
nums[i] = nums.splice(Math.floor(Math.random()*nums.length), 1, nums[i]);
}
trace(nums);
var num1 = nums[0];
var num2 = nums[1];
var num3 = nums[2];
var num4 = nums[3];
var num5 = nums[4];
//
trace(num1+" "+num2+" "+num3+" "+num4+" "+num5);
None of them work. Any other way to get a different, random number for each variable? help PLEASE!
Scratch- just like Flash without "Syntax Error" (yeah, that's me on the front page. I mean, was me)
-
Is there a way to do it using variables not strings?
Scratch- just like Flash without "Syntax Error" (yeah, that's me on the front page. I mean, was me)
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
|