1

AS3 で縦横比を維持しながら画像をスケーリングする必要があります。ステージ全体のサイズに合わせてスケーリングする必要がありますが、何も切り取ってはいけません。

どうやってするの?

ありがとう、ウリ

4

1 に答える 1

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;
于 2012-11-21T22:47:29.597 に答える