Jump to content
Search Community

tweening in array

chefkeifer test
Moderator Tag

Recommended Posts

i have a list of ingredients that are doing into a bowl one after another and i tried to simplify the code..and cannot get it to work..

 

old code

var intro:TimelineMax = new TimelineMax({repeat:-1});
               intro.insert(TweenMax.to(pepper1, 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}));
intro.insert(TweenMax.to(pepper2, 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), .25);
intro.insert(TweenMax.to(pepper3, 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), .50);
intro.insert(TweenMax.to(pepper4, 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), .75);
intro.insert(TweenMax.to(tom1,    1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}),   1);
intro.insert(TweenMax.to(tom2,    1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), 1.25);
intro.insert(TweenMax.to(tom3,    1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), 1.50);

 

simplified code that does not work...only one ingrdient come out and tweens

var ingrd:Array = [ing1, ing2, ing3, ing4, ing5, ing6, ing7];
//*****====================================================*****\\
var activeTween:TimelineLite;

for (var i:int = 0; i < ingrd.length; i++) {
  activeTween = new TimelineLite({paused:true});
  activeTween.append(TweenMax.to(ingrd[i], 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), .25);
}

function init():void {
     activeTween.play();
}
init();

 

what am i doing wrong. i want one ingredient to follow the same path but tween every .25 seconds after the other...does that make sense

Link to comment
Share on other sites

var ingrd:Array = [ing1, ing2, ing3, ing4, ing5, ing6, ing7];
var tl:TimelineMax = new TimelineMax({repeat:-1, paused:true});
tl.appendMultiple( TweenMax.allTo(ingrd, 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}, 0.25) );

 

Or, if you'd rather not use the allTo() method, you could do a manual loop like:

 

var ingrd:Array = [ing1, ing2, ing3, ing4, ing5, ing6, ing7];
var tl:TimelineMax = new TimelineMax({repeat:-1, paused:true});
for (var i:int = 0; i    tl.insert( TweenMax.to(ingrd[i], 1, {bezier:[{x:293, y:134}, {x:235, y:345}], scaleX:.25, scaleY:.25}), i * 0.25);
}

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