Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement