Jump to content
Search Community

How to alter the tween parameters of tl.add

blissville test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I'm trying to alter the tween properties of tl.add() function. I have written this code

public function progressBar(min:int, sec:int){
  var s:int = convertMintoSec(sec, min);

  var t = TweenMax.to(mc_pbDisplay.mc_pb, s, {
    x: 225,
    y: 21.10,
    scaleX: 0
  });
  tl.add(t);
}

What  I want to achieve is to change the value of variable s and restart the tween with the new value of s. but the tween retains the initial value of s. 

  1.  how can i change the value of variable s?
  2. how can i kill tl.add(t) and re-initialize it with the new tween properties of t? i have tried this
    tl.kill();
    progressBar(min, sec);
    tl.restart();

    But but variable s still retains its initial value

Link to comment
Share on other sites

Right, invalidate() will force the tween to re-record the starting/ending values but it looks like the variable "s" in your case is plugged into the duration of the tween; you can update the duration anytime like:

 

tweenInstance.duration(newDuration);

 

Also, I wouldn't recommend calling kill() on a timeline if your plan is to restart() it. Perhaps you meant tl.clear() to empty it of all its child animations? 

 

Does that help?

  • Like 2
Link to comment
Share on other sites

Thanks guys. I actually got it to work with .invalidate() method. I figured i didn't need the tl.add() function. I could easily control my tween which is an instance of TweenMax() with pause(), play(), restart() directly. so the .invalidate() method worked fine. And yes  I initially tried this tweenInstance.duration(newDuration); but didn't work probably because I was applying the method to TimelineMax instead of TweenMax which is the actual instance of my tween.

Thanks for the help 

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