A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] [F8] Array grid

  1. #1
    Senior Member layerburn's Avatar
    Join Date
    Jul 2006
    Location
    USA
    Posts
    542

    resolved [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=0i<ALL_MODS.lengthi++){
        
    //attaching all modules in movement.xml to stage for testing
        
    this.attachMovie("modBox","m"+i,i, {_x:+ (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 
    1;
    var 
    0;
    var 
    letter:Array = Array("a","b","c","d","e","f","g");
    for(var 
    i=1i<ALL_MODS.lengthi++){
        
    //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:+ (65 colNum) , _y:47 + (45 rowNum)});

        
    colNum++;
        
    n++;
        if(
    colNum == 5){
            
    rowNum++;
            
    colNum 0;
        }
        if(
    n==5){
            
    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.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    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);
    	};
    }

  3. #3
    Senior Member layerburn's Avatar
    Join Date
    Jul 2006
    Location
    USA
    Posts
    542
    That's it! Thanks a ton dawsonk, I've been going over this for days. I really appreciate your help.
    This is your brain. This is your brain on script.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center