Image resize issue


max_height = 500;
max_width = 500;
_root.picture.loadMovie("http://fritz.msn.ee/album/audes105/pilt2.jpg");
function size() {
 if (picture._width>picture._height and picture._width>max_width) {
  picture._height = Math.floor(max_height*picture._height/picture._width);
  picture._width = max_width;
 } else if (picture._height>picture._width and picture._height>max_height) {
  picture._width = Math.floor(max_height*picture._width/picture._height);
  picture._height = max_height;
 }
}
this.onEnterFrame = function() {
 total = picture.getBytesTotal();
 loaded = picture.getBytesLoaded();
 if (loaded == total && loaded>4) {
  size();
 }
};
button.onRelease = function() {
 _root.picture.loadMovie("http://fritz.msn.ee/album/audes105/pilt3.jpg");
};
 

It’s a small part form a bigger script. The prblem is:

it resizes the first picture perfectly, but after i click the button, the new image comes out waay too small, i cant find the error anywhere :frowning:

pilt2 is 19522608
pilt3 is 500
375