/ Published in: ActionScript
Expand |
Embed | Plain Text
/** * Determines which size is smaller and resizes the other size to the same percentage * *@param clip The movieclip to resize *@param w The maximum width to resize to *@param h The maximum height to resize to *@param overflow A boolean to determine if the image should overflow the visual area (no blank space) */ function resizeProportionally(clip:MovieClip, w:Number, h:Number, overflow:Boolean):Void { // Determine percentage var hPer:Number = w/clip._width; var vPer:Number = h/clip._height; if (overflow) { // Use biggest var percent:Number = Math.max(hPer, vPer); } else { // Use smallest var percent:Number = Math.min(hPer, vPer); } clip._width = (clip._width)*percent; clip._height = (clip._height)*percent; }
You need to login to post a comment.
