PDA

View Full Version : Gerenate random attachMovie


Mvespa
02-17-2006, 05:46 PM
Hi!

I'm developing a game and the objective is to drag some objects to a container. Some objects add points, and some other subtract points.
So, all the objects are in the library and have a linkage name to be called by attachMovie.
I want to create an Array with all the objects that belong to container, like for example filename1 = ["obj1", "obj2", "obj3"]; etc...
I have a var called count1 that defines the number of objects to appear on the Scene
So what I have is:


count1 = 5;

function createTest() {
filename1 = ["obj1", "obj2"];
i = filename1.length;
k = Math.floor(Math.random()*i);
for (i=0; i<count1; i++) {
vazio1.attachMovie(filename1[i], filename1[i], i);
}
}


When I test this, only appears two objects because the array as only two objects, but what I want is to show "obj1+i" and "obj2+i" = 5 objects

How can I do this? Show 5 objects radomly, using obj1 and obj2?

Thanks

PS: Sorry about my english

Paerez
02-17-2006, 06:08 PM
like this:

count1 = 5;

function createTest() {
filename1 = ["obj1", "obj2"];
for (i=0; i<count1; i++) {
k = Math.floor(Math.random()*filename1.length);
vazio1.attachMovie("obj"+k"-"+i, filename1[k], i);
}
}