Jump to content
GreenSock

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

Restarting an animation TweenLight

Recommended Posts

Hi,

 

I am having trouble restarting an animation. I have a function that I call when the the timeline gets to a movieclip but when I leave that section on the timeline and come back the functions do not restart they duplicate so that two sets of the same function are running at different times.

 

 

function f_anim(){
TweenLite.from(pic0, 1, {_alpha:0, overwrite:0, delay:0.5});
TweenLite.from(pic0, 11, {_x:-100, _y:-40, _xscale:100, _yscale:100, overwrite:0, delay:0.5});
 
TweenLite.from(txtA1, 0.5, {transformAroundCenter:{_xscale:300, _yscale:300}, _alpha:0, blurFilter:{blurX:20, blurY:20}, ease:Circ.easeIn, overwrite:0, delay:1});
}
 
f_anim();
 
How can I stop everything that is happening in f_anim and start it again from the beginning? Any help would be appreciated. Thanks,
Matt
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

Not really picturing exactly what is happening.

 

 

If you are trying to combat a previously created tween, you want overwriting to happen (don't set it to 0). In v12 the default mode is auto, which is what most people want. Are you using v12 or v11?

 

With overwrite mode auto, If tween B is animating the same properties of Tween A, Tween A will be killed immediately. By setting overwrite:0, you are saying "make sure this tween does not get interrupted .  If you are using v11, you would want to set auto mode like so

 

 

OverwriteManager.init(OverwriteManager.AUTO);

 

http://www.greensock.com/overwritemanager/

 

-----

 

 

Also, keep in mind that from() tweens can be a little dangerous if you are trying to recreate them while other instances are running.

 

Imagine mc has a current _x = 100.

You do this type of tween

 

 

TweenLite.from(mc, 1, {_x:0, ease:Linear.easeNone})
 

You would expect that tween to change the _x FROM 0 to 100. 

 

Now imagine half way through when the _x = 50, you go somewhere else in your timeline and then come back real quick... The next time that tween runs, mc will have an _x:50 and the new tween will tween from 0 to 50. It will never get to the original 100 that you had intended. To get around that type of issue you would do

 

 

 

function anim() {
//always make sure _x is 100 prior to the tween being created
mc._x = 100;
TweenLite.from(mc, 1, {_x:100 ...});
}
 

 

 

 
Let us know if any of this info helps. If not, feel free to provide a very basic sample that only has enough code and assets to replicate the issue and we will help you out.
Link to comment
Share on other sites

Thank you, your response makes sense to me but when I look at what is happening it appears that the .from() function appears to be happening twice. Like the last one is not being removed when the second one is starting. I trued using the overwrite manager but nothing happened.

 

Thanks,

Matt

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.
×