Actionscript 3 ActionScript 3位图宽度与高度成比例

Actionscript 3 ActionScript 3位图宽度与高度成比例,actionscript-3,bitmap,Actionscript 3,Bitmap,我将此位图定义为: [Embed(source="images/floorplan.png")] var Floorplan:Class; var floorplanImg:Bitmap = new Floorplan(); floorplanImg.y = 510; floorplanImg.x = 40; floorplanImg.height = 890; 我想做的是设置高度,让宽度与高度成比例。我试着用谷歌搜索我的问题,但我看到的只是如何缩放位图图像。我已经有很长一段时间没有做动作脚

我将此位图定义为:

[Embed(source="images/floorplan.png")]
var Floorplan:Class;

var floorplanImg:Bitmap = new Floorplan();
floorplanImg.y = 510;
floorplanImg.x = 40;
floorplanImg.height = 890;

我想做的是设置高度,让宽度与高度成比例。我试着用谷歌搜索我的问题,但我看到的只是如何缩放位图图像。我已经有很长一段时间没有做动作脚本3了,我似乎无法理解这一点。请提供帮助。

在AS3中,您可以使用显示对象的
scaleX
&属性来维护本机纵横比

以下是按比例缩放项目的常用方法:

floorplanImg.height = 890; //when you change the height, it automatically changes the scaleY to the relative amount from the original (1)
floorplanImg.scaleX = floorplanImg.scaleY; //make the scaleX the same as the new scaleY to keep the aspect ratio the same
比例属性基本上只是相对宽度/高度的替代品-
1
为本机尺寸,
2
为尺寸的两倍,
0.5
为一半等