Jump to content
Search Community

How can I create a lettersArray as mentioned in the example?

learner_7n test
Moderator Tag

Recommended Posts

Hi,

 

How can I create an array as given in the example (below link)?

 

http://www.greensock.com/timelinemax/

 

import com.greensock.*;

 

var timeline:TimelineMax = new TimelineMax({repeat:2, yoyo:true, repeatDelay:1.5});

timeline.append( TweenLite.from(blackBar, 0.8, {x:550}) );

timeline.insertMultiple( TweenMax.allFrom([logo, timelineWord, maxWord, byGreenSock], 0.5, {autoAlpha:0}, 0.25), 0.6);

timeline.insertMultiple( TweenMax.allFrom(lettersArray, 1, {y:"-30", alpha:0, ease:Elastic.easeOut}, 0.04), 1.4);

 

I have created other movie clips and text boxes but could not understand on how to make an lettersArray as in the above code to work with this example. Could someone help me out, please>

 

Thanks

Link to comment
Share on other sites

an array in its simplest terms allows you to create a list of items.

 

see: http://www.republicofcode.com/tutorials ... as3arrays/

 

the code you gave implies that you have an array that stores the names of all the movie clips you want to animate.

 

so you would do something like this:

 

var lettersArray:Array = new Array(a_mc, b_mc, c_mc, d_mc);

 

you would also have to have movie clips on the stage with instance names a_mc, b_mc, c_mc

 

now when you call

 

timeline.insertMultiple( TweenMax.allFrom(lettersArray, 1, {y:"-30", alpha:0, ease:Elastic.easeOut}, 0.04), 1.4);

 

each movie clip that is referenced in lettersArray will tween

 

you could literally tween 100s of movie clips in this fashion

Link to comment
Share on other sites

Yep, Carl is right (as usual) but just to add a little extra tip: SplitTextField can make this very easy. Let's say, for example, you have a TextField with a paragraph of text (literally like 100 characters). It would be a BIG pain to split that apart in the IDE, select each character one-by-one and make them into MovieClips and/or give them instance names so that you can reference them in your array. That's precisely what SplitTextField was built for - you simply feed your TextField to SplitTextField and it will automatically break it apart so that each character, word, or line is in its own TextField. It populates a "textFields" array for you and then you can feed that to whatever you want. So to animate hundreds of characters that you have in a single TextField into place, it could be as simple as:

 

var stf:SplitTextField = new SplitTextField(myTextField);
TweenMax.allFrom(stf.textFields, 1, {y:"-200", autoAlpha:0, ease:Elastic.easeOut}, 0.05);

 

Learn more about SplitTextField at http://www.greensock.com/splittextfield/ (it's a membership benefit of Club GreenSock by the way, so it's not in the public downloads).

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