Jump to content
Search Community

Tweening a clip from different points

AndyC test
Moderator Tag

Recommended Posts

Let's say I have a movie clip, with an x coordinate equal to the width of the stage, which I want to move to the far left of the stage; the function would be:

 

TweenMax.to(clip, 10, {_x:0});

 

How would I code the tween if the clip was in the centre of the stage, assuming I want it to move at the same speed? A revised function would be:

 

TweenMax.to(clip, 5, {_x:0});

 

But do I have to calculate duration of the tween myself? Is there a TweenMax property that allows me to modify TweenMax.to(clip, 10, {_x:0}) so that the clip moves at the same speed regardless of its starting position?

 

And what if I want to loop the tween so that when the clip reaches its destination (x=0) it is sent to the far left of the stage each iteration, regardless of where it started? Can TweenMax handle this in a single method?

 

I am quite possibly overlooking a very simple solution to this, but I'd be grateful to anyone who can point it out!

 

[EDIT]

Link to comment
Share on other sites

here is a tutoria, interactive demo, and source files for generating tweens with constant speed regardless of distance travelled:

http://www.snorkl.tv/2010/11/tweenlite- ... -traveled/

 

 

to start at center stage, tween all the way left and then start again all the way to the right, it might be easier just to have 2 tweens and repeat the second 1.

 

or with 1 tween only you could do this:

 


import com.greensock.*;
import com.greensock.easing.*;


//set the mc all the way to the right
mc._x = Stage.width;

//create a tween that tweens from left to right
var tween:TweenMax = TweenMax.to(mc, 4, {_x:0, repeat:-1, ease:Linear.easeNone});

//start the tween in the middle
tween.currentProgress = .5

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