Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex AS3:调整处理程序拉伸图像的大小_Apache Flex_Actionscript 3 - Fatal编程技术网

Apache flex AS3:调整处理程序拉伸图像的大小

Apache flex AS3:调整处理程序拉伸图像的大小,apache-flex,actionscript-3,Apache Flex,Actionscript 3,我有一个图像加载器,我试图动态调整大小。 我想确保纵横比保持不变,这样图像就不会拉伸。 当我重新加载图像(通过加载程序用另一个图像重新填充图像)时,会调用一个resize函数。我想知道这部分调整大小代码可能有什么问题: var aspect:Number = width / height; var cAspect:Number = _imageBoundary.width / _imageBoundary.height; if (aspect <= cAspect) { _ld

我有一个图像加载器,我试图动态调整大小。 我想确保纵横比保持不变,这样图像就不会拉伸。 当我重新加载图像(通过加载程序用另一个图像重新填充图像)时,会调用一个resize函数。我想知道这部分调整大小代码可能有什么问题:

var aspect:Number = width / height;
var cAspect:Number = _imageBoundary.width / _imageBoundary.height;

if (aspect <= cAspect) 
{
    _ldr.height = _imageBoundary.height;
    _ldr.width = aspect * _ldr.height;
}
else 
{
    _ldr.width = _imageBoundary.width;
    _ldr.height = _ldr.width / aspect;
}

_ldr.x = (_imageBoundary.width - _ldr.width) / 2 + _imageBoundary.x;
_ldr.y = (_imageBoundary.height - _ldr.height) / 2 + _imageBoundary.y;
var aspect:Number=宽度/高度;
var cAspect:Number=\u imageBoundary.width/\u imageBoundary.height;

if(aspect我认为最简单可靠的方法是使用Image类。 您可以在这里看到一个很好的示例:

Image类可能会在其源字段中动态更改并相应地加载映像


希望有帮助。

我认为第一行应该是

var aspect:Number = _ldr.content.width / _ldr.content.height;

谢谢你的参考——目前我正在寻找一个AS3唯一的解决方案。很漂亮。谢谢你发现了这一点。