Created
June 15, 2012 18:48
-
-
Save mattlundstrom/2938136 to your computer and use it in GitHub Desktop.
Flash Proportional Resize To Fit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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