Jump to content


Updating tweens on the fly to _start_ from a new point?

Recommended Posts

I'm curious if there's a way to update a TweenMax on the fly so that it will continue to its original destination but from new start points. I see how to update the destination.


I'm asking because I have a situation in which I have a Tween in progress but sometimes (randomly) I will want to stop that tween and have the object head somewhere else. If it is clicked on it should stop its new tween and go where it was supposed to go originally. My solution was to pause the original tween, save it in a variable in the object, make a new tween -- and then if the object is clicked to kill the new tween, grab the old tween and resume it. But it doesn't seem to work quite right.


Thanks for any help. Just pointing me to the right part of the API would be fine.


(Alternatively, of course, I could simply save the final destination and make an an entirely new tween to that place, but I was curious if the above would work)

Link to comment
Share on other sites

I think your best bet is to have the object store the original destination values and create new tweens each time.


You can try this


1: create new fla

2: create movieclip with instance name mc

3: move mc to top right of stage

4: add this code:



import com.greensock.*; 
import flash.events.MouseEvent;

//original tween
mc.tween = TweenLite.to(mc, 4, {x:525, y:375});

//interupt tween after 1 second
TweenLite.delayedCall(1, goSomewhereElse);

function goSomewhereElse(){
TweenLite.to(mc, 10, {x:510, y:0});
TweenMax.set(mc, {tint:0xff0000});

//click on mc after it turns red
mc.addEventListener(MouseEvent.CLICK, resume);

function resume(e:MouseEvent):void{

test the fla, when the mc turns red (new tween started) click on the mc.

It will go back to where it was when the original tween was interrupted and then resume to the end.


I don't think this is what you want. I'm guessing you want the object to continue from its existing place when clicked. If so, you will need a new tween.


Hope this helps.

Link to comment
Share on other sites

Thanks -- I tried your code but indeed what I wanted was from from the current point to the original destination. In the interim I had stored the the final destination, and that works fine, but I was curious if there were another way/


Would "invalidate" work?

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.