-
Senior Member
[RESOLVED] [F8] Array grid
I have an array that has 35 objects in it pulled from xml. I am trying to replicate a movieclip on the stage for each of the objects in a grid format (rows and columns). However I want to take the first 5 in the array, make movieclips on the stage for them, and name them A1, A2, A3, A4, and A5. The next 5 would be a row under that called B1 B2 B3 B4 and B5, and so on for the entire array. Here's what I am working off of so far, only the movieclips are named m0 all the way up through m35, I need to change this to row 1 starting with A1 through A5, row 2 starts with B1 through B5, and so on.
This is what i'm starting with.
PHP Code:
var rowNum = 0;
var colNum = 0;
for(var i=0; i<ALL_MODS.length; i++){
//attaching all modules in movement.xml to stage for testing
this.attachMovie("modBox","m"+i,i, {_x:8 + (65 * colNum) , _y:47 + (45 * rowNum)});
colNum++;
if(colNum == 10){
rowNum++;
colNum = 0;
}
var cur_mc = this["m"+i];
cur_mc.text_txt.text = ALL_MODS[i];
}
This is what i tried, but it only worked for the first 4, after that nothing.
PHP Code:
var rowNum = 0;
var colNum = 0;
var n = 1;
var l = 0;
var letter:Array = Array("a","b","c","d","e","f","g");
for(var i=1; i<ALL_MODS.length; i++){
//attaching all modules in movement.xml to stage for testing, converting to appropriate names ie: A1 vs B1
this.attachMovie("modBox",letter[l]+n,i, {_x:8 + (65 * colNum) , _y:47 + (45 * rowNum)});
colNum++;
n++;
if(colNum == 5){
rowNum++;
colNum = 0;
}
if(n==5){
n = 1;
l++;
}
}
Any help would be greatly appreciated. Thanks for your help in advance.
Best,
burn
This is your brain. This is your brain on script.
-
Code:
var letter = Array("a", "b", "c", "d", "e", "f", "g");
var rowNum = 0;
var colNum = 0;
var colMax = 5;
for (var i = 0; i < ALL_MODS.length; i++) {
//attaching all modules in movement.xml to stage for testing
var cur_mc = this.attachMovie("modBox", letter[rowNum] + (colNum + 1), i, {_x:8 + (65 * colNum), _y:47 + (45 * rowNum)});
colNum++;
if (colNum == colMax) {
rowNum++;
colNum = 0;
}
cur_mc.text_txt.text = ALL_MODS[i];
cur_mc.onRollOver = function() {
trace(this._name);
};
}
-
Senior Member
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
|