Dynamically loaded jpgs, not able to resize them dynamically, it resizes to odd sizes

Hi,

i am using the movieClipLoader class (AS2, Flash 8 Pro) and loading some images into a movieclip called PicHolder in a flash webpage. I want the images to be not more than 500x300 so if the image is more than 500 pixels in width then after loading it should scale to within 500 on the x scale.

I used movieClipLoader and also added a listener and onLoadInit event to trigger the sizing. onLoadInit i have a trace to show the current x and y widht and height of the PicHolder clip AFTER the jpg has loaded.

Everything works well and it correctly reports the x and y size of the jpg pic thats coming in. But when i add 1 more line saying

if (width>=500) {PicHolder._width=500};

It does all sorts of funny things such as resizing even pics which are not more than 500 pixels wide. I think its something to do with the onLoadInit or maybe it resizes the first pic and after that its maintaining the scaled values and using that so im getting a superimposed effect when i load the next pic.

Any ideas how this should be done ? Because when we drop some images into the local folder, its possible that some of them might be large and i want them all to fit within a 500x300 space.