Posted By

fergc on 06/16/12


Tagged


Versions (?)

getNewSize


 / Published in: ActionScript 3
 

resize pics

  1. var pct:Number = getNewSizeMax(content.width, content.height, mask_mc.width * 1.1, mask_mc.height * 1.1);
  2. content.scaleX *= pct;
  3. content.scaleY *= pct;
  4.  
  5. private function getNewSizeMax(initW:Number, initH:Number, endW:Number, endH:Number):Number
  6. {
  7. var pct:Number = 1;
  8. var pct2:Number = 1
  9. var retorno:Number;
  10. if (initW != endW)
  11. pct = extartPercent(initW, endW);
  12. if (initH != endW)
  13. pct2 = extartPercent(initH, endH);
  14. if(pct > pct2)
  15. retorno = pct;
  16. else
  17. retorno = pct2;
  18. return retorno;
  19. }
  20.  
  21. private function extartPercent(n1:uint, n2:uint):Number
  22. {
  23. return n2 / n1;
  24. }

Report this snippet  

You need to login to post a comment.