Dynamicly populated grid

Hello,

I hope that someone here can help me. Here it goes. I am populating my flash scene with a dynamic grid whitch consists of MCs that contain a button. There are generated in 90 buttons Y and 120 buttons X. Making a tottal of 10.800 buttons that are generated.

I will post my code for better understanding. I have two different MCs. One, square is normal, and the other, square_s is the occupied state of the button.

Now i would like to import a xml file, that would have a id number of the field and the state of it (normal or occupied). That id field would than be compared to the “k” variable in the code bellow. And than depending on the xml state of the button it would display the propper MC. I am a beginner at AS, so i would be very grateful for any help given to me.

In the code;

if(k==2 or k==2010){
duplicateMovieClip (“square_s”, “square_s”+k, k);

// setting the x position of the duplicated square movieclips
    setProperty ("square_s"+k, _x, distance*i);
    // setting the y position of the duplicated square movieclips
    setProperty ("square_s"+k, _y, distance*j);
    // incrmenting the value of k
    k++;
    }

i was just testing to see if i set a random number of a field, if it will dissplay correctly. The new code should be something like this;

if(k==(id.variable.from.xml)){

And one more thing. How could i apply a link in the code bellow, so it woul generate dynamicly. Ex. index.php?field="(The K variable)"? I just dont know how to do it.

I hope it is not too complicated or anythink. I bet that it isnt going to be souch a problem for all you experts out there.:wink: I would like to thank everyone in advance. Thank you.


// Variable xgridlines is defined for number of grid lines on x axis
xgridlines = 91;

// Variable ygridlines is defined for number of grid lines on y axis
ygridlines = 91;
// Variable distance is defined for the distance between each grid
distance = 10;

// set property function is used to make the square movieclip invisible
setProperty ("square", _visible, false);
setProperty ("square_s", _visible, false);
// Variable k is used in the forloop for
// giving different instance name to the duplicated movieclips
k = 1;

// Making a nested forloop for duplicating the square movieclip
for (j=1; j<=xgridlines-1; j++) {
    for (i=1; i<=ygridlines-1; i++) {
        // duplicating the square movieclip
        
        if(k==2 or k==2010){
        duplicateMovieClip ("square_s", "square_s"+k, k);
        
    // setting the x position of the duplicated square movieclips
        setProperty ("square_s"+k, _x, distance*i);
        // setting the y position of the duplicated square movieclips
        setProperty ("square_s"+k, _y, distance*j);
        // incrmenting the value of k
        k++;
        }else{
            
        duplicateMovieClip ("square", "square"+k, k);
        // setting the x position of the duplicated square movieclips
        setProperty ("square"+k, _x, distance*i);
        // setting the y position of the duplicated square movieclips
        setProperty ("square"+k, _y, distance*j);
        // incrmenting the value of k
        k++;
        }

    
    }
}