Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 15, 2012 18:48
Show Gist options
  • Save mattlundstrom/2938136 to your computer and use it in GitHub Desktop.
Save mattlundstrom/2938136 to your computer and use it in GitHub Desktop.
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment