i'm loading images dynamically. The images that will be
uploaded will very rarely be of the exact same dimensions, so
scaling percent wise doesn't exactly do what I want. I would like
to scale an image up and down to a precise amount of pixels (say,
I don't know if this is what your looking for, but try this:
var newXScale:Number = (116/uplImage._width)*100;
var newYScale:Number = (86/uplImage._height)*100;
uplImage._xscale = newXScale;
uplImage._yscale = newYScale;
This will, however, not respect the original aspect ratio of
your image. If you want to keep the aspect ratio, you should filter
out the smallest scale and set the xscale and yscale to that value.
once the image is loaded completely (onLoadInit Event must be
fired if using MovieClipLoader) you can access the size of the
image via the _width and _height properties.
The logic to code would be to check the size of the image and
check if it fits into a virtual bounding box that marks the max
width and height for the images as they should be dispayed.
If one (or both) sides of the image exceeds the maximum
width, calculate the percentage by which you must scale the image
down to fit this sied into the "box". Apply this factor to BOTH the
widht and the height, then check if the other side of the image is
still to big to fit into the box and repeat the downscaling if