Advertisement
ulfben

FlashGallery scaling routine

Jul 18th, 2011
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //TODO: missbehaves on rectangular images?
  2. //http://wordpress.org/support/topic/square-images-cropped-in-fullscreen?replies=7#post-2227942
  3. function fitToScreen(mc:MovieClip) {   
  4.     var maxHeight:Number = Stage.height-25;
  5.     ZigoEngine.doTween (mc,"_x",0,0,"linear",0,function () {   
  6.     if(mc._height <= maxHeight && mc._width <= Stage.width){           
  7.         mc._yscale = mc._xscale = 100;     
  8.     }
  9.     if(_scalingStrategy != _NOSCALE){
  10.         if(mc._height < mc._width) {
  11.             mc._width = Stage.width;       
  12.             mc._yscale = mc._xscale;
  13.             if(_scalingStrategy == _FILL){
  14.                 if (mc._height < maxHeight) {
  15.                     mc._height = maxHeight;
  16.                     mc._xscale = mc._yscale;
  17.                 }
  18.             }
  19.         }else {
  20.             mc._height = maxHeight;
  21.             mc._xscale = mc._yscale;       
  22.         }  
  23.     }
  24.     mc._x = Stage.width/2 - mc._width/2;
  25.     mc._y = maxHeight/2 - mc._height/2;
  26.     });
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement