Jump to content


lock scale ratio while [SOLVED]

Recommended Posts

Hey is there an easy way to lock the width and height ratio? I'm trying to set the width of the mc equal to the stage but have the height keep to scale also. So the wider I open my stage the taller the mc gets also. :S Thanks in advance.


sizeXListener = new Object();

sizeXListener.onResize = resizerX;


function resizerX() {




Link to comment
Share on other sites

Sure, you'd just need to do the math:


var ratio:Number = main.height / main.width;
function resizerX() {
   var w:Number = Math.floor(Stage.width); 
   TweenLite.to(main,0,{_width:w, _height:w * ratio});

Link to comment
Share on other sites

  • 1 month later...

Thanks a lot. I found an article on it but your solution is ten times shorter. Your brain must be really heavy. :mrgreen:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.