mattlundstrom
6/15/2012 - 6:48 PM

Flash Proportional Resize To Fit

Flash Proportional Resize To Fit

function proportionalResizeToFit(resizingMC:Object, referenceMC:Object, useHeight:Boolean){

	var origWidth:Number = resizingMC.width;
	var origHeight:Number = resizingMC.height;
	var ratio:Number = origHeight / origWidth;

	if (useHeight){
		resizingMC.height = referenceMC.height;
		resizingMC.width = resizingMC.height / ratio;
	} else {
		
		resizingMC.width = referenceMC.width;
		resizingMC.height = resizingMC.width * ratio;
	}	
}