Jump to content
Search Community

Add ThrowProps tween to a Timeline

Mark test
Moderator Tag

Recommended Posts

Hello,

 

I"m wondering how to start a timeline with a ThrowProps Tween.

this is the code i have for the Throw:

 

ThrowPropsPlugin.to(mScrollContainer,{throwProps:{y:{velocity:yVelocity, min:targetY-20, max:targetY-20, resistance:4000}
},ease:Power3.easeOut
},1,.25,0);
 
works great.  Now i want to append some animations afterwards, but i'm not sure how... What would be the proper way to write the code below? Where the throwprops is the 1st item in the timeline?
 
var moveToLock:TimelineLite = new TimelineLite();
 
moveToLock.append( // THROW PROPS ANIMATION GOES HERE // );
moveToLock.append( new TweenLite(mScrollContainer,.2,{y:targetY,ease:Power3.easeIn}) );
moveToLock.append( new TweenLite(mScrollContainer,.03,{y:"-5",ease:Linear}) );
moveToLock.append( new TweenLite(mScrollContainer,.1,{y:targetY,ease:Power3.easeIn}) );
 
 
any assistance would be warmly appreciated.
 
Sincerely,
 
Mark
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The first thing to point out is that ThrowPropsPlugin.to() returns a TweenLite instance.

As long as you can reference that tween, you can add it to a timeline.

 

here is an example I built using your code (which i slightly modified for the unknown variables)

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
import com.greensock.plugins.ThrowPropsPlugin;


TweenPlugin.activate([ThrowPropsPlugin]);




var throwTween:TweenLite = ThrowPropsPlugin.to(mScrollContainer,{throwProps:{y:{velocity:200, min:0, max:1000, resistance:100}
},ease:Power3.easeOut
},1,.25,0);


var tl = new TimelineLite();
tl.add(throwTween) //place throwTween at the beginning of the timeline
tl.to(mc2, 1, {y:400}); // when throwTween ends the next tween begins
The above code works with v12 of the platform. You could still use append() instead of add(), but append() has been deprecated.
 
I would strongly suggest moving away from append() and using the newer add(), from() and to() methods of TimelineLite.
Link to comment
Share on other sites

Ah thank you Carl!  Your explanation is clear. I just starting using throwprops and didn't realize it returned a tween that way... This is much better than using oncomplete:

 

and thanks for pointing out the deprecated methods. I'll switch to add()

 

Great work. Greensock is amazing.

 

-Mark

  • Like 1
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...