//Finally came around to rewrite this: http://pastebin.com/tvnz57eQ
//fixing _FIT of near-rectangular pictures & _FILL-behaviour (filling on both axis)
function fitToScreen(mc:MovieClip) {
mc._yscale = mc._xscale = 100;
var maxHeight:Number = Stage.height-25;
if(_scalingStrategy == _FIT){
var getWidthRatio:Number = mc._width / mc._height;
var getHeightRatio:Number = mc._height / mc._width;
if(Stage.width > maxHeight){
mc._height = maxHeight;
mc._width = Math.round(maxHeight*getWidthRatio);
}else{
mc._width = Stage.width;
mc._height = Math.round(Stage.width*getHeightRatio);
}
}else if(_scalingStrategy == _FILL){
mc._width = Stage.width;
mc._yscale = mc._xscale;
if(mc._height < maxHeight){
mc._height = maxHeight;
mc._xscale = mc._yscale;
}
}
mc._x = Stage.width*0.5 - mc._width*0.5;
mc._y = maxHeight*0.5 - mc._height*0.5;
}
Comments
0 B
|👍
/👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎
0 B
|👍
/👎