Posted By

chopbust on 03/30/12


Tagged


Versions (?)

Resize 2 movieclips and mask the smaller one.


 / Published in: ActionScript
 

Resizes the item based on the mask. Must be on the same stage.

  1. private function resizeBasedOnMask(pic:Object, masker:Object) {
  2.  
  3. var scaler:Number;
  4.  
  5. if (pic.width > pic.height) {
  6. pic.height = masker.height;
  7. pic.scaleX = pic.scaleY;
  8. } else {
  9. pic.width = masker.width;
  10. pic.scaleY = pic.scaleX;
  11. }
  12.  
  13. pic.x = -((pic.width - masker.width) / 2);
  14. pic.y = -((pic.height - masker.height) / 2);
  15. pic.mask = masker;
  16.  
  17. }

Report this snippet  

You need to login to post a comment.