Jump to content

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

Multiples targets with multiple values

Recommended Posts

This had to be discussed but i can't find a topic about it.


Is there a way to do something like :

var obj1 = { myValue:random };
var obj2 = { myValue:random };
TweenMax.to([obj1, obj2, ...], d, { myValue:[value1, value2, ...] });

when at the end :

obj1.myValue // value1
obj2.myValue // value2


Link to post
Share on other sites

Of course a for loop do the job...

var objs = [...];
var values = [...];
for (var i = 0; i < objs.length; i++)
    TweenMax.to(objs[i], d, { myValue:values[i] });

But we have to declare two arrays first, a single line would be more elegant!

Link to post
Share on other sites

Eh? What? Not sure what the question is.


But, if you want to cycle thru several values in several elements, the cycle method is your friend. ;)


Check out the link but here's the basic usage using your example as a basis:

TweenMax.staggerTo([obj1, obj2, ...], d, { cycle:{myValue:[value1, value2, ...]} });

If you omit the stagger amount, it will behave as a simple .to() tween, by the way.

  • Like 6
Link to post
Share on other sites

You may have not understood the question, but you managed to provide the answer !

staggerTo was the keyword, thanks for that

  • Like 1
Link to post
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.