我需要在AS3中保持纵横比来缩放图像。它应该缩放到整个舞台大小,但不应该被切断。
怎么做?
谢谢你, 乌利
答案 0 :(得分:8)
这样的事情应该有效:
// set the scale to fit the width of the image to the width of the stage
var scale:Number = stage.stageWidth / myImage.width;
// if the height of the image will be taller than the stage,
// set the scale to fit the height of the image to the height of the stage
if(myImage.height * scale > stage.stageHeight){
scale = stage.stageHeight / myImage.height;
}
// apply the scale to the image
myImage.scaleX = myImage.scaleY = scale;