Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
jinisner

Easing in and out in a slow manner

Recommended Posts

Hi folks,

 

I am jin , please accept my wishes , i have been working on as3 for some time now but was never good with animations, i came across this package and i can say this is nothing short of a miracle to me to be able to get the effects that greensock can provide ....

 

In order to add more value to my projects i am trying to add a camera zoom in and out at certain points in my project , now i can do this by using the below code -

 

TweenLite.to(WorldObj, 0, {scaleX:1.5, scaleY:1.5});

 

this zoom in remain for 3 seconds and then i do this to get to normal size -

 

TweenLite.to(WorldObj, 0, {scaleX:1, scaleY:1});

 

But the zoom in and out happens rather abrubptly like in a fraction of a second , i want it to be a bit slow , i came across a thread that suggests this -

 

TweenLite.delayedCall(2, slowDown);

               function slowDown() {
                 
                    TweenLite.to(WorldObj, 1, {x:0,y:0,scaleX:1.5, scaleY:1.5});
                    }

 

i tried it, but it does  not seem to do the work , can any one please guide me as to where i am going wrong and what i can do to make it work .....

 

 

Once again thanks in advance and hope to be able to contribute after some time ....

 

Regards

 

 

 

Share this post


Link to post
Share on other sites

Hi Jin and welcome to the GreenSock forums.

 

What you could do is attach the function to scale the element down to an onComplete call in the tween that scales the element up, like this:

import com.greensock.*;

//define the tween in a variable, is easier to access later
//like that you can reverse and play the tween on different events
var t = TweenLite.to(mc1, 1, {scaleX:1.5, scaleY:1.5, onComplete:scaleDown});

function scaleDown()
{
	TweenLite.delayedCall(3, t.reverse);
}

Like that when the tween ends it'll call the scaleDown function and 3 seconds later the tween will reverse, getting back to the element's normal scale.

 

Rodrigo.

  • Like 1

Share this post


Link to post
Share on other sites

@rhernando- thanks a lot sir , i will try it and get back to you ....

 

Regards

Jin

Share this post


Link to post
Share on other sites

Also please note that both of your tweens had 0 as the duration, which means they take 0 seconds to complete.

TweenLite.to(WorldObj, 0, {scaleX:1.5, scaleY:1.5});

TweenLite.to(WorldObj, 0, {scaleX:1, scaleY:1});

To make your tweens have a duration and play slower you should provide a non-zero duration.

 

This tween will have a duration of 4 seconds:

TweenLite.to(WorldObj, 4, {scaleX:1.5, scaleY:1.5});

Share this post


Link to post
Share on other sites

You may also want to change the ease to something like Power2.easeIn or Power2.easeInOut (and of course, as Carl said, make sure the tween has a non-zero duration)

Share this post


Link to post
Share on other sites

@rhernando,@carl,@greensok - thanks a lot for the amazing support ....

 

I have tried the code as mentioned by both @rhernando and @carl , when i add a non zero value like here---

 

var t = TweenLite.to(level1WorldObj, 3, {scaleX:1.5, scaleY:1.5, onComplete:scaleDown});

                    function scaleDown()
                    {
                            TweenLite.delayedCall(3, t.reverse);
                    }

 

 

or like this -

 

TweenLite.to(level1WorldObj, 3, {x:0,y:0,scaleX:1.5, scaleY:1.5});

 

 

However when i try the first method i get the error -

 

TypeError: Error #1010: A term is undefined and has no properties. at scaledown function

 

 

And when i try the single line with out the function like here -

TweenLite.to(level1WorldObj, 3, {x:0,y:0,scaleX:1.5, scaleY:1.5});

 

it does slow down the process but the entire world starts shaking while the tweening is taking place ...

 

I must be doing something wrong or missing something , your guidace is needed here ....

 

Thanks in advance for your time and patience with my queries ....

 

Regards

Jin

Share this post


Link to post
Share on other sites

It sounds like there is something else wrong with your code. I just tested this and it works fine:

 

import com.greensock.*;


var t = TweenLite.to(level1WorldObj, 3, {scaleX:2, scaleY:2, onComplete:scaleDown});


function scaleDown() {
TweenLite.delayedCall(1, t.reverse); 
}

I have attached a zipped FLA, please feel free to modify that file so that it can produce the error you are seeing. We don't need to see your full production files, but if you want to create your own super-simplified example, that's fine too.

 

 

scaleUpDown_CS5.zip

Share this post


Link to post
Share on other sites

@carl - Once again thanks a lot for your patience ... your file has helped a lot ....

 

What seems to be the problem is that i am working with box2d physics engine , now if i do the animation just on the movieclip it works well ....

 

But when i create a world and then put objects inside it , for example a bike rider and the focus is set on the rider  inside the world ...

 

When the world zooms it seems to vibrate every thing , however if used out side of physics world it works fine ...

 

Can you please guide me to some link here which suggests use of greensock with box2d , i searched but was unable to find one ....

 

I found this one but it does not have any answer -

 

http://forums.greensock.com/topic/4415-tween-physics-box2d/

 

Once again thanks a lot for  the amazing support ....

 

Regards

Jin

Share this post


Link to post
Share on other sites

Well it sounds like Box2D is certainly fighting for control over the properties you are trying to tween. Sorry, but I've never used Box2D beyond reading a few tutorials (years ago). Don't know what to suggest here.

 

You might find this article:

http://www.ghost23.de/2011/02/using-tweens-with-box2d-2-0-1/

 

and other Google results of Tweening and Box2D helpful.

Share this post


Link to post
Share on other sites

@carl - thanks a lot for the help , with so many games in box2d i am sure some one must have found away of using it ....i will ley you know if i find a solution ....

 

Once again thanks for your support ....

 

Regards

Share this post


Link to post
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.

×