Revision: 13967
Updated Code
at April 6, 2011 01:02 by sidneydekoning
Updated Code
/* You can responds to any stage resize event by proportionally scaling the image to fill the stage. Since scaleX and scaleY are percentages, it's just a matter of figuring out which property is larger and making the two equal. By swapping the scale comparison from greater than to less than, the object will scale proportionally to fit the larger of the two dimensions given. This kind of calculation is handy when you need to fit items of variable dimensions into a fixed space. */ // set image dimensions to match stage or the object you want to scale to; image.width = stage.stageWidth; // Or object.width image.height = stage.stageHeight; // Or object.height // choose the larger scale property and match the other to it; ( image.scaleX < image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY; // choose the smaller scale property and match the other to it; ( image.scaleX > image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
Revision: 13966
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 14, 2009 10:06 by sidneydekoning
Initial Code
/* You can responds to any stage resize event by proportionally scaling the image to fill the stage. Since scaleX and scaleY are percentages, it’s just a matter of figuring out which property is larger and making the two equal. By swapping the scale comparison from “greater than†to “less thanâ€, the object will scale proportionally to fit the larger of the two dimensions given. This kind of calculation is handy when you need to fit items of variable dimensions into a fixed space */ // set image dimensions to match stage; image.width = stage.stageWidth; image.height = stage.stageHeight; // choose the larger scale property and match the other to it; ( image.scaleX < image.scaleY ) ? image.scaleY = image.scaleX : image.scaleX = image.scaleY;
Initial URL
http://en.wikipedia.org/wiki/Image_scaling
Initial Description
Initial Title
Proportional Scaling Techniques
Initial Tags
Initial Language
ActionScript 3