Actionscript 3 AS3-将图像缩放到全宽或全高而不截断

Actionscript 3 AS3-将图像缩放到全宽或全高而不截断,actionscript-3,scale,Actionscript 3,Scale,我需要在AS3中保持纵横比来缩放图像。应将其缩放至整个舞台尺寸,但不应切断任何东西 怎么做 谢谢,, Uli类似的方法应该会奏效: // 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 t

我需要在AS3中保持纵横比来缩放图像。应将其缩放至整个舞台尺寸,但不应切断任何东西

怎么做

谢谢,,
Uli

类似的方法应该会奏效:

// 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;

像这样的方法应该会奏效:

// 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;