snilbert
07-29-2003, 06:21 PM
Hi, I'm trying to make an array of the numbers 1 to 100 to correspond with 100 movieclips with the same name. Then I'm trying to randomise this list, and then select however many from the new ordered list.
So far I'm just working in trace mode to test it, but I've noticed that each time I try and create the new list, among the numbers 1 to 100, is a blank space, if you understand what I mean.
I think it's something to do with actionscript counting the first element as 0, whereas in my for loop creating the numbers, I start from 1 and make all numbers less than 101. I've noticed that when I start this from 0 and limit it to numbers less than 100, I don't get the blank in the randomised list.
I attach it below. I want to be able to do it without having to renumber my movieclips from 0 to 99, which will be time consuming. Is it possible, without getting the blanks?
onClipEvent (load) {
list = new Array();
for(i=1;i<101;i++){
trace(list[i] = i);
}
randomList = new Array();
while (list.length>1) {
r = int(Math.random()*list.length);
randomList.push(list[r]);
trace(list.splice(r,1));
}
}
If you scroll down the output window you'll see the blank.
Much appreciate any wisdom anyone can show me...:cool:
So far I'm just working in trace mode to test it, but I've noticed that each time I try and create the new list, among the numbers 1 to 100, is a blank space, if you understand what I mean.
I think it's something to do with actionscript counting the first element as 0, whereas in my for loop creating the numbers, I start from 1 and make all numbers less than 101. I've noticed that when I start this from 0 and limit it to numbers less than 100, I don't get the blank in the randomised list.
I attach it below. I want to be able to do it without having to renumber my movieclips from 0 to 99, which will be time consuming. Is it possible, without getting the blanks?
onClipEvent (load) {
list = new Array();
for(i=1;i<101;i++){
trace(list[i] = i);
}
randomList = new Array();
while (list.length>1) {
r = int(Math.random()*list.length);
randomList.push(list[r]);
trace(list.splice(r,1));
}
}
If you scroll down the output window you'll see the blank.
Much appreciate any wisdom anyone can show me...:cool: