Thumbnails gallery

Hello, i modified kirupas thumbnail gallery script to generate a grid thumbnail gallery:

the old script was like in the tutorials:

tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};

i modified it to align the thumbnails on a grid:

tlistener.onLoadInit = function(target_mc) {
if ( target_mc._width < target_mc._height) {
target_mc._width = 24;
target_mc._height = 36;
target_mc._x = posx + 17;
target_mc._y = posy;
posx += 65;
}
else {
target_mc._width = 60;
target_mc._height = 36;
target_mc._x = posx;
target_mc._y = posy ;
posx += target_mc._width +5;
}
if (posx > 220) {
posx = 0;
posy += target_mc._height + 5;
}
trace (“x,y”+target_mc._x +","+target_mc._y);
target_mc.pictureValue = k;

this does the following:
first it checks if it is a landscape thumbnail or a portrait, then it sets the width/height for the pictures.
after it puts thumbnails in x direction until 220 is reached then it adds a row (posy) and starts from the first column.
This works fine in Internet explorer. But in firefox 2.0.0.4 and flash player 9 i get random order of the thumbnails. The scrolling thumnails script worked for me in firefox…
Any ideas? thanks