Jump to content
Search Community

TweenMax.allTo dynamic values

friendlygiraffe test
Moderator Tag

Recommended Posts

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

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