Flash AS3 Function: Scale and Resize a MovieClip in Proportion
One of the things that drives me nuts is when you have to scale or resize a movie clip and keep it in proportion at the same time. So I created this function to do all the heavy lifting, all you have to do is pass it the movie clip and give it the max dimension size and it does all the rest of the hard work.
function resize(mc:MovieClip, maxDimension:int):MovieClip { //already under the maxDimension if (mc.width <= maxDimension && mc.width <= maxDimension) return mc; else { var divisor = ( mc.width >= mc.height) ? mc.width / maxDimension : mc.height / maxDimension; mc.width = Math.floor(mc.width / divisor); mc.height = Math.floor(mc.height / divisor); } return mc; }