Jump to content
Search Community

Tweening multpile objects

Guest newdevide
Moderator Tag

Recommended Posts

Guest newdevide

Guys, i have about 20 mc's that i multipled using 'for' method

how do animate them without writing each name individually?

I look at the greensock example;

 

timeline.insertMultiple( TweenMax.allTo([box1, box2, box3], 1, {tint:0x90E500, scaleX:0.2, scaleY:0.2}), timeline.duration );

 

but the prob is it's only 3 mc's, and it's simple using it (i think).

 

and since i used for to duplicate each mc i have to use getChildByName("name0") to direct me to the object and then write it again and again and again.

 

Is there a better and easy way? Thx

Link to comment
Share on other sites

while you are "multiplying' your movie clips inside your for loop add a line of code that will push a reference to that movie clip into an array.

you can then use that array in your allTo.

 

i don't know what code you are using but it could look something like this

 

var movieclips_arr:Array = []

for (var i:int = 0; i   var newMC:MovieClip = new WhateverTheClassOfYourSymbolInTheLibraryIs();
 addChild(newMC)

movieclips_arr.push(newMC);
}

 

timeline.insertMultiple( TweenMax.allTo(movieclips_array, 1, {tint:0x90E500, scaleX:0.2, scaleY:0.2}), timeline.duration );

Link to comment
Share on other sites

Guest newdevide

Thx for the quick reply man, i'll get on it and let you know if it works. By the way if i wanted a different x and y position for each mc, do i also have to put the position in an array?

Link to comment
Share on other sites

if you want different positions, you can't use allTo. allTo requires that ALL objects are going TO the same values.

 

yes, you could keep all the positions in an array and then loop through the array to get the values.

Link to comment
Share on other sites

this is one way

 

var mcs:Array = [car_mc, bike_mc, plane_mc]
var xPos:Array = [100, 220, 350]

var tl:TimelinLite = new TimelineLite();

for(var i:int = 0 ; i
tl.append(TweenLite.to(mcs[i], 1, {x:xPos[i]}));

}

Link to comment
Share on other sites

Guest newdevide

Well it works, but not the way that i hope it would be. It doesn't tween at the same time. Although it sure saves a lot of scripting line.

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