Jump to content
GreenSock

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

TweenMax.allTo dynamic values

Recommended Posts

Hi I want to tween a group but with separate destinations. Is this possible or do they all have to have the same target?

var Letters:Array = [let1, let2, let3, let4];

var Dest:Array = [123, 5, 67, 345];

TweenMax.allTo(Letters,3,{_y:Dest[?]});

Link to comment
Share on other sites

TweenMax.allTo() is for taking all the objects in an array and making them all go to common destination values. So no, you cannot use allTo() to define different destination values. Just do something like this instead:

 

var Letters:Array = [let1, let2, let3, let4];
var Dest:Array = [123, 5, 67, 345];
var i:Number= Letters.length;
while (i--) {
   TweenMax.to(Letters[i], 3, {_y:Dest[i]});
}

Link to comment
Share on other sites

Hey there- Here's an add-on question for this post. What if I want to sequence the Array objects (to the same location)? For instance:

 

var timeline:TimelineLite = new TimelineLite();
var Letters:Array = [let1, let2, let3, let4];
var i:Number= Letters.length;
while (i--) {
   timeline.insertMulitple(TweenLite.allFrom(Letters[i], 3, {y:0}, 1, TweenAlign:SEQUENCE, 1);
}

 

This throws me a Type Coercion error. Can you tell me why? Thanks!

Link to comment
Share on other sites

Why are you doing an allFrom() with only one object? Remember, allFrom() is for taking an ARRAY of objects and making them all go to a common set of tween values. So your code had several problems:

 

1) You weren't passing an array to allFrom()

 

2) You were missing an ")" after the first "1".

 

3) TweenLite doesn't have allFrom() - only TweenMax does.

 

I think you meant to do either something like this:

var timeline:TimelineLite = new TimelineLite();
var Letters:Array = [let1, let2, let3, let4];
timeline.insertMulitple( TweenMax.allFrom(Letters, 3, {y:0}, 1) );

 

-OR-

 

var timeline:TimelineLite = new TimelineLite();
var Letters:Array = [let1, let2, let3, let4];
var i:Number= Letters.length;
while (i--) {
   timeline.insert( TweenLite.from(Letters[i], 3, {y:0}), i * 1);
}

 

(I'm not sure which one you wanted but hopefully this gives you a nudge in the right direction).

Link to comment
Share on other sites

Excellent! Sorry for the sloppy code, i should have looked at it more closely before posting that. Appreciate your help though! Thanks!

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