ActionScript 3 AS3按比例调整大小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3按比例调整大小相关的知识,希望对你有一定的参考价值。
/**
* resize
* Take input diemnsion and return the resulting dimensions using a ratio
* @param _w initial width
* @param _h initial height
* @param _targetW targeted width
* @param _targetH targeted height
* @param _ratio set the ratio manually instead of automatically detecting it (0)
* @return An object containing both resulting dimensions :object.width,object.height
*/
function resize(_w:Number,_h:Number,_targetW:Number,_targetH:Number,_ratio:Number = 0):Object {
var ratio:Number = (_ratio ==0) ? _w / _h : _ratio;
var rW:Number = _targetW;
var rH:Number = _targetH;
if (ratio >= 1) {
rH = _targetW / ratio;
if (rH > _targetH) {
rH = _targetH;
rW = rH * ratio;
}
}else {
rW = _targetH * ratio;
if (rW > _targetW) {
rW = _targetW;
rH = rW / ratio;
}
}
var newDimensions:Object = {width:rW,height:rH };
return newDimensions;
}
以上是关于ActionScript 3 AS3按比例调整大小的主要内容,如果未能解决你的问题,请参考以下文章
AS3按比例调整大小
ActionScript 3 AS3将DisplayObject调整为Rectangle
ActionScript 3 AS3按名称调用函数
ActionScript 3 AS3按类名获取类引用
ActionScript 3 AS3按名称将对象转换为类
ActionScript 3 在AS3中排序多维数组(按字母顺序)