Jump to content
GreenSock

Ghelle

Mixing two tweens on single object without overwright

Recommended Posts

Hello,

 

I have many object moving on board using TweenMax an I need to add one more tween to all the objects including board they are on, so that all objects move like they are nested in one MovieClip and whole MovieClip is scrolled. I don't want to overwrite, I want to mix two tweens on same objects.

 

Is this possible?

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

I am having difficulty understanding the question. If you could post a very simple fla example that better illustrates what you are trying to do it would be most helpful.

 

You can zip your fla and attach it using the "more reply options" button.

 

--

 

If you want to avoid overwriting you can pass overwrite:"none" to any tween like so

TweenLite.to(mc, 1, {x:200, overwrite:"none"});
Link to comment
Share on other sites

You are wanting to COMBINE multiple tweens, right? For example:

mc.x = 0;
TweenLite.to(mc, 1, {x:300});
TweenLite.to(mc, 1, {x:500});

You'd want mc.x to end at 800, right? So the effects of the tweens are compounded. 

 

The answer is "no". That would actually have a pretty big impact on performance because on every...single...update, it'd have to both read and write values rather than just writing. There are also some inherent logic problems with that type of system unless ALL of the values are all interpreted as relative but that'd be harder for you because what if you want something to land EXACTLY at x:100 (or whatever). You'd have to do the math up front to figure out the relative amount and then what if there are other tweens affecting the object, all layering on top of what you're trying to do - it'd throw off your results and x could end up being something completely different. 

 

You can certainly use a generic object and an onUpdate to get the effect you're after. It's just a little more work :)

Link to comment
Share on other sites

Thanks for your support!

 

I did it by using dummy variable for .y position and changed real .y on tween update. As I see, that's what you said in last sentence. I just saw the post.

Thanks!

Code:
 

import com.greensock.*;

var zeroPoint = 0;
objOnBoard.tY = objOnBoard.y;

TweenMax.to(this, 2, {onRepeat:moveObjOnBoard, repeat:-1});

function moveObjOnBoard():void{
	TweenMax.to(objOnBoard, 1, {tY:objOnBoard.tY-50, onUpdate:objOnBoardTweenUpdate});
}

function objOnBoardTweenUpdate():void{
	objOnBoard.y = zeroPoint + objOnBoard.tY;
}


TweenLite.to(movingBoard, 10, {y:200, onUpdate:boardTweenUpdate});

function boardTweenUpdate():void{
	zeroPoint = movingBoard.y;
	objOnBoard.y = movingBoard.y + objOnBoard.tY
}

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