Scaling a DisplayObject to fit to a container’s dimensions


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var scale:Number = ((container.height/container.width) > (image.height/image.width)) ? (container.width/image.width) : (container.height/image.height);
  2. image.scaleX = scale;
  3. image.scaleY = scale;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.