Logic Error or Flash MX Limitation

This is my problem that I have been fighting for way too long. I have a grid with some 300 boxes in it. I want these boxes to populate the grid randomly with random number of boxes populating each time.

My grid is a MC and all of the squares in it are the child of a another MC. All squares are named 1-300 and as you can see in the array, I am testing just 18 right now.
I am hoping that it is possible to do what I want to do with an array because I think it would save me a lot of time and save computers a lot of processor juice.

I have been able to get the setProperty to affect the squares that the array points to, but it won’t move on to any other squares. Or it will make the entire MC invisible.

I would REALLY apreciate some help on this one.

CODE for frame 1:
//This code should wipe the grid clean
Boxes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
for (count = 0; count<=18; count++) {
&nbsp &nbsp &nbsp &nbsp setProperty(Boxes[count], _visible, false);

CODE for frame 2:
//This should randomly polulate the grid
var RanBox; //Random Box Movie Clip
var MaxTimes; //Limit of times runable
trace (MaxTimes = random(5));
for (TR = 0; TR<=MaxTimes; TR++) { //Times Run
&nbsp &nbsp &nbsp &nbsp RanBox = random(1:cool: ;
&nbsp &nbsp &nbsp &nbsp setProperty(Boxes[RanBox], _visible, true);

If you’re reading this now, YOU’RE A ROCK STAR because I was sure that I would have lost most peoples attention by now. If you come up with a solution, you’re a Flash Diety (much better than a rock star).

I don’t know what that @#%$ smiley face is doing in the middle of that code, but it is supposed to be random (1:cool: ;

K. You can tell I’m new here. Dern Emoticons. That was random (18);

I will send you my .fla grid that I am working on if you like.

Nevermind. i can’t figure it out. I don’t know why its not working, I changed the code. Modified your code, and still i can’t get it to work. someoen else will have something sorry.

you gonna post that .fla?

Is there a place in this form that people can send files to for others to download. I doubt it. I will set up a simple FTP site tonight if necessary, but I would just prefer to email it to you if you want it. Get in touch with me at [email protected]

naming movies numbers can be problematic. also, you can do it without the array if your just cycling through numbers anyhow.

maybe try naming them m0, m1, m2… then change that code to read:

n = 18
   _root["m"+n]._visible = random(2);

otherwise you could put them all in a movie, say it was named “grid”, and use a for in loop to interate through everything in grid:

for(m in _root.grid){
   _root.grid[m].visible = random(2);

then it doesn’t matter if you name them at all! just keep in mind that code will act on everything in _root.grid.

whoops, i only read the first part of your post. to change just a few of them on, you’ll want to slice the array (copy it) and remove numbers as you operate on them so that you don’t get duplicates.

this is assuming you name the movies m0, m1, m2… and put them in _root.grid:

t = _root.boxes.slice();
reps = 6;
   _root.grid["m"+t.slice(random(t.length),1)]._visible = 1;

change the for in loop in the above post to set visible = 0 and that’ll reset them.

  • edited to fix code error*

Thanks for checkin this. I will see if it works for me when I get home.