New issue 86 by iworkinprogress: AlignUtil.scaleToFit
http://code.google.com/p/sekati/issues/detail?id=86
What steps will reproduce the problem?
1.scale to fit a rectangle inside of another rectangle that is not
fullscreen.
What is the expected output? What do you see instead?
- Should fit object to fit within outer rectangle. Right now, it does, but
on resize it pops between scale to fit width and scaling to fit height.
Please use labels and text to provide additional information.
- To fix, we should use a different conditional to determine if we should
fit scale to width ratio or height ratio.
For example:
public static function scaleToFit(item : DisplayObject,targetW :
Number,targetH : Number,center : Boolean) : void {
var widthRatio: Number = targetW / item.width;
var heightRatio: Number = targetH / item.height;
if(widthRatio < heightRatio) {
item.width = targetW;
item.scaleY = item.scaleX;
} else {
item.height = targetH;
item.scaleX = item.scaleY;
}
if (center) {
item.x = int( targetW / 2 - item.width / 2 );
item.y = int( targetH / 2 - item.height / 2 );
}
}
Comment #1 on issue 86 by sekati: AlignUtil.scaleToFit
http://code.google.com/p/sekati/issues/detail?id=86
released with 3.0.6.1