Jump to content
Search Community

Scale proportional to screen size?

olleka test
Moderator Tag

Recommended Posts

Hi

I have a movieclip that I want to tween fro 0 to 100 % of the screen size when the tween runs.

 

I have set it up so that the mc scales with the screen.

 

boy._width = Stage.width/2

boy._height = Stage.height/2

boy._xscale <= boy._yscale ? (boy._xscale = boy._yscale) : (boy._yscale = boy._xscale); // keeps boy proportional

 

But now I want to add a tween from 0 to 100% wit a delay, dependent of screen size. How would I do that?

 

I did read about AutoFit area but don't know how to or where I can find out more.

 

My actionscript is rather limited ;)

 

I use AS 2 in this project.

 

Regards

Olle

Link to comment
Share on other sites

AutoFitArea is only for AS3, so it won't help you.

 

Your code looks like it resizes the object to half the size of the stage, not the full size. Is that what you want? I suspect I might be misunderstanding what you want exactly, but if the goal is to tween your object to the width/height of the stage, it should be as simple as:

 

TweenLite.to(mc, 1, {_width:Stage.width, _height:Stage.height});

 

Of course you should adjust that whenever the screen is resized.

Link to comment
Share on other sites

Hi.

Thanks for answering.

 

Slight missundertanding because I explained it poor.

 

The goal is to open a fullscreen window.

I want to tween a photo in the fullscreen window.

 

So I need to scale the photo proportional to keep it look wierd in a wide screen for instance.

If i go just TweenLite.to(mc, 1, {_width:Stage.width, _height:Stage.height}); the image gets very wide in a wide screen.

It would work for a backround or similar.

 

But this image needs to have the same proportions in every screensize.

 

So I guess it' the height of the picture that desides what percetage to scale the image.

 

So what I ended up with now that works somewhat, but not perfect is that I put the mc to be tweened inside a container mc.

container._width = Stage.width/2
container._height = Stage.height
container._xscale <= container._yscale ? (container._xscale = container._yscale) : (container._yscale = container._xscale); // keeps boy proportional 

TweenLite.to(container.boy, 0.75, {_xscale:60, _yscale:60, delay:0.7, ease:Elastic.easeInOut});

 

Maybe there is a smarter way i'm sure ;)

 

Regards

Olle

Link to comment
Share on other sites

So maybe you're looking for something like this?:

 

var imageRatio:Number = boy._width / boy._height; //store the original (unscaled) ratio here

//then, anytime you need to tween/scale it...
var stageRatio:Number = Stage.width / Stage.height;
if (stageRatio > imageRatio) {
   TweenLite.to(boy, 0.75, {_width:Stage.height * imageRatio, _height:Stage.height, delay:0.7, ease:Elastic.easeInOut});
} else {
   TweenLite.to(boy, 0.75, {_width:Stage.width, _height:Stage.width / imageRatio, delay:0.7, ease:Elastic.easeInOut});
}

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.
×
×
  • Create New...