Unhappy adjusting columns and rows on stage resize, according to Stage.width

Hey fello flashers,

what i’m trying to achieve can be seen here, at the [COLOR=Red]FWA’s website[/COLOR].

When you resize the browser window the thumbnails rows and columns adjust accordingly to fit.I’ve managed to attach the thumbnails correct when my enableButtons() function is called but i’m unsure how to approach resizing.

if anyone has encounted this problem before or can help, then pls do i’m a little confounded on this one.

thanks
cam

[COLOR=#993300]Stage[/COLOR].[COLOR=#993300]align[/COLOR] = [COLOR=#0000FF]“TL”[/COLOR];

[COLOR=#993300]var[/COLOR] numberOfGalleries:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]20[/COLOR];
[COLOR=#993300]var[/COLOR] thumbMarginX:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]163[/COLOR];
[COLOR=#993300]var[/COLOR] thumbMarginY:[COLOR=#993300]Number[/COLOR] = [COLOR=#000000]109[/COLOR];

[COLOR=#993300]function[/COLOR] initCOLOR=#000000[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
enableButtonsCOLOR=#000000[/COLOR];
resizeStageCOLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] enableButtonsCOLOR=#000000[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
currentRow = [COLOR=#000000]0[/COLOR];
currentColumn = [COLOR=#000000]0[/COLOR];
[COLOR=#993300]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000000]0[/COLOR]; i<numberOfGalleries; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
tracker = i;
thumbsDisplayer = [COLOR=#993300]this[/COLOR].[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]“thumbsDisplayer_mc”[/COLOR], [COLOR=#993300]this[/COLOR].[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];
currentThumbnail = thumbsDisplayer.[COLOR=#993300]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]“thumbnail holder”[/COLOR], [COLOR=#0000FF]“thumbnail”[/COLOR]+COLOR=#000000[/COLOR], thumbsDisplayer.[COLOR=#993300]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];

    currentThumbnail.[COLOR=#993300]_x[/COLOR] = currentColumn*thumbMarginX;
    currentThumbnail.[COLOR=#993300]_y[/COLOR] = currentRow*thumbMarginY;
    currentColumn++;
    [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]currentThumbnail._x&gt;[COLOR=#000000]([/COLOR][COLOR=#993300]Stage[/COLOR].[COLOR=#000000]width[/COLOR]-[COLOR=#000000]([/COLOR]currentThumbnail.[COLOR=#993300]_width[/COLOR] + thumbMarginX[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        currentRow++;
        currentColumn = [COLOR=#000000]0[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]

[COLOR=#993300]function[/COLOR] resizeStageCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]var[/COLOR] myListener:[COLOR=#993300]Object[/COLOR] = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];
myListener.[COLOR=#993300]onResize[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#F000F0]*// *[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]Stage[/COLOR].[COLOR=#993300]addListener[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

initCOLOR=#000000[/COLOR];

it required the integration of these two magical functions…

function stageWidth(){
    var thumbwidth:Number = Math.ceil((sortArray[0]._width+90));
    
    for(i=0;i<7;i++){
        num = i-1;
    if(Stage.width <= thumbwidth*i && Stage.width >= thumbwidth*num){
        columnVar = i
        }
    }
}


function sort() {
    counter = 0;
    for (i=0; i<Math.ceil(sortArray.length/2); i++) {
        for (j=0; j<columnVar; j++) {
            if (counter<sortArray.length) {
                with (sortArray[counter]) {
                    _y = i*thumbMarginY;
                    _x = j*thumbMarginX;
                }
                counter++;
            }
        }
    }
}

function resizeStage() {
    var myListener:Object = new Object();
    myListener.onResize = function(e:Object):Void  {
        stageWidth();
        sort();
    };
    
    Stage.addListener(myListener);
}