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

**URL:** <https://forum.kirupa.com/t/unhappy-adjusting-columns-and-rows-on-stage-resize-according-to-stage-width/259970>\
**Category:** Uncategorized\
**Created:** [May 11, 2008, 2:53am UTC](https://forum.kirupa.com/t/unhappy-adjusting-columns-and-rows-on-stage-resize-according-to-stage-width/259970 "2008-05-11T02:53:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camoconnell\_com](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/camoconnell_com/32/3655_2.png) [@camoconnell\_com](https://forum.kirupa.com/u/camoconnell_com)\
**Post date:** [May 11, 2008, 2:53am UTC](https://forum.kirupa.com/t/unhappy-adjusting-columns-and-rows-on-stage-resize-according-to-stage-width/259970/1 "2008-05-11T02:53:20Z")

</div>

Hey fello flashers,

what i’m trying to achieve can be seen here, at the [[COLOR=Red]FWA’s website[/COLOR]](http://www.thefwa.com/).

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];

---

<div class="post-metadata">

**Author:** ![camoconnell\_com](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/camoconnell_com/32/3655_2.png) [@camoconnell\_com](https://forum.kirupa.com/u/camoconnell_com)\
**Post date:** [May 12, 2008, 6:45am UTC](https://forum.kirupa.com/t/unhappy-adjusting-columns-and-rows-on-stage-resize-according-to-stage-width/259970/2 "2008-05-12T06:45:11Z")

</div>

it required the integration of these two magical functions…

```php
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);
}

```
