SHARE
TWEET

FlashGallery scaling fixed

ulfben Dec 27th, 2011 134 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Finally came around to rewrite this: http://pastebin.com/tvnz57eQ
  2. //fixing _FIT of near-rectangular pictures & _FILL-behaviour (filling on both axis)
  3. function fitToScreen(mc:MovieClip) {   
  4.         mc._yscale = mc._xscale = 100;
  5.         var maxHeight:Number = Stage.height-25;
  6.         if(_scalingStrategy == _FIT){
  7.                 var getWidthRatio:Number = mc._width / mc._height;
  8.                 var getHeightRatio:Number = mc._height / mc._width;                    
  9.                 if(Stage.width > maxHeight){
  10.                         mc._height = maxHeight;
  11.                         mc._width = Math.round(maxHeight*getWidthRatio);
  12.                 }else{
  13.                         mc._width = Stage.width;
  14.                         mc._height = Math.round(Stage.width*getHeightRatio);
  15.                 }      
  16.         }else if(_scalingStrategy == _FILL){
  17.                 mc._width = Stage.width;               
  18.                 mc._yscale = mc._xscale;                               
  19.                 if(mc._height < maxHeight){
  20.                         mc._height = maxHeight;
  21.                         mc._xscale = mc._yscale;
  22.                 }
  23.         }
  24.         mc._x = Stage.width*0.5 - mc._width*0.5;
  25.         mc._y = maxHeight*0.5 - mc._height*0.5;
  26. }
RAW Paste Data
Top