# ANOTHER image resize question!

**URL:** <https://forum.kirupa.com/t/another-image-resize-question/180665>\
**Category:** flash\
**Created:** [March 2, 2006, 12:59pm UTC](https://forum.kirupa.com/t/another-image-resize-question/180665 "2006-03-02T12:59:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blindart](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@blindart](https://forum.kirupa.com/u/blindart)\
**Post date:** [March 2, 2006, 12:59pm UTC](https://forum.kirupa.com/t/another-image-resize-question/180665/1 "2006-03-02T12:59:01Z")

</div>

1st post, hooray! :pleased: First off, thanks to everyone who has posted examples/tutorials on this excellent site, you’ve helped me get a lot of difficult (for me anyway!) stuff done quickly.  
So…I’ve followed the tuts on the site and written||cut’n’paste a few bits together that resize my picture to the border’s size.

> **function resizePic** (w,h){  
> var x\_scale = y\_scale = scale = 100;  
> x\_scale=border.\_width/w;  
> y\_scale=border.\_height/h;  
> scale = Math.min(x\_scale, y\_scale)\*100;  
> picture.\_xscale = picture.\_yscale = scale;  
> }

\*\* function loadPic\*\*(pic){  
picture.loadMovie(pic, 1);  
\*\* this.onEnterFrame\*\* = function() {  
f = picture.getBytesTotal();  
l= picture.getBytesLoaded();  
preloader.\_visible = true;  
if (l!= f) {preloader.preload\_bar.\_xscale = 100\*loaded/filesize;}  
else {preloader.\_visible = false;  
if (picture.\_alpha\<100){  
picture.\_alpha += 10;  
}  
}  
picture.\_xscale = picture.\_yscale = 100;  
if(picture.\_width\>border.\_width||picture.\_height\>border.\_height){  
resizePic(picture.\_width, picture.\_height);  
}  
}  
}

First; this code didn’t work properly until I put the ‘this.onEnterFrame’ section just before the resizePic function is called. Why?

Second; I’ve noticed a lot of times ‘onEnterFrame’ is called, its deleted again further down the code. Should I be doing so in this case? Why is it normally deleted? Memory managent?

Thanks for any help!
