Uli*_*Uli 1 scale actionscript-3
我需要在AS3中保持纵横比来缩放图像.它应该缩放到整个舞台大小,但不应该切断任何东西.
怎么做?
谢谢你,乌利
这样的事情应该有效:
// 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;
Run Code Online (Sandbox Code Playgroud)