Jump to content
Search Community

Is there an easier way to do this?

booglebop test
Moderator Tag

Recommended Posts

It seems like this should be able to be compacted into one line of code. I'm struggling to figure out how. I'm familiar with appendMultiple etc...but this is three different tweens on the same MC so I'm confused.

 

researchIntroAnim.append(TweenMax.from(introCopy1, 0.25, {delay:0, scaleX:0, scaleY:0, ease:Strong.EaseIn}));
researchIntroAnim.append(TweenMax.to(introCopy1, 3, {delay:0, scaleX:1.1, scaleY:1.1, ease:Linear.easeNone}));
researchIntroAnim.append(TweenMax.to(introCopy1, 0.25, {delay:0, scaleX:8, scaleY:8, autoAlpha:0, ease:Strong.EaseOut}));

Link to comment
Share on other sites

There's nothing wrong with using 3 lines instead of one, but you could do this:

 

researchIntroAnim.appendMultiple( [TweenMax.from(introCopy1, 0.25, {scaleX:0, scaleY:0, ease:Strong.EaseIn}), 
                                 TweenMax.to(introCopy1, 3, {scaleX:1.1, scaleY:1.1, ease:Linear.easeNone}),
                                 TweenMax.to(introCopy1, 0.25, {scaleX:8, scaleY:8, autoAlpha:0, ease:Strong.EaseOut})], 0, TweenAlign.SEQUENCE);

Link to comment
Share on other sites

Thanks. researchIntroAnim is actually a pretty long sequence. introCopy1 is just a tiny part of it. Would this be a good place to use a nested timeline? Things are just getting kind of tedious with all of the delays and negative delays to overlap things the way that I would like to.

Link to comment
Share on other sites

Sure, nest away. You should rarely (if ever) have to use delays in your tweens when you're putting them into a TimelineLite/Max. Use the offset value in the timeline append()/insert()/whatever methods. I noticed your code had delay:0 for all 3 of your tweens which is unnecessary. It's always 0 by default.

 

I find that nesting timelines can make your work much more modular and easy to manage, especially in projects where you've got a lot to put into a timeline.

Link to comment
Share on other sites

Sure, look at the append() and insert() and appendMultiple() and insertMultiple() methods in the ASDocs. And check out the video at http://www.greensock.com/timeline-basics/ - it mentions it there too. Basically, if you want to append a tween to the end of a timeline but leave a 1 second gap between the end of the timeline and the insertion point of the tween, do myTimeline.append(myTween, 1);

Link to comment
Share on other sites

Ahh...found it. I actually watched that video before and must have forgotten. I understand how to offset with the append()/insert() methods but l want to offset an entire sequence of tweens. For example:

timeline.appendMultiple(TweenMax.allFrom([MC_1, MC_2, MC_3], 0.25, {scaleX:0, scaleY:0, ease:Back.easeOut},0),1);

Should scale MC_1,MC_2 and MC_3 to 100% respectively, (0.25 sec per tween) and staggering by 1 sec. Is that "0" (the second to last param) the offset param? Would that offset each one or would it offset the entire sequence?

 

You should rarely (if ever) have to use delays in your tweens when you're putting them into a TimelineLite/Max.

What are the advantages of using "offset" as opposed to "delay"?

 

I noticed your code had delay:0 for all 3 of your tweens which is unnecessary. It's always 0 by default.

Yes, I usually just put the 0 delay as a placeholder as I am almost always changing it to try and overlap/align things in a certain way. I have really long TimeLines (30 objects) or so and many lines of code, including appendMultiple and insertMultiple, but still end up needing the delays. I know there should be an easier way but haven't found it yet. Perhaps, I need to explore the offset param more. Any organizational tips for looooooong TimelineMax/Lites?

Link to comment
Share on other sites

For example:

timeline.appendMultiple(TweenMax.allFrom([MC_1, MC_2, MC_3], 0.25, {scaleX:0, scaleY:0, ease:Back.easeOut},0),1);

Should scale MC_1,MC_2 and MC_3 to 100% respectively, (0.25 sec per tween) and staggering by 1 sec. Is that "0" (the second to last param) the offset param? Would that offset each one or would it offset the entire sequence?

 

Actually, the stagger parameter in TweenMax.allFrom() and the stagger parameter in appendMultiple() do the same thing. Use whichever one you want. The offset parameter of appendMultiple(), however, just offsets the initial inssertion point for the whole set of tweens (kinda like a delay for the whole thing). Make sense?

 

What are the advantages of using "offset" as opposed to "delay"?

 

Whatever floats your boat. Doesn't really matter which one you use. The delay property would technically travel with the tween so you could get it if you nest the tween elsewhere, but most people don't need/use that anyway.

 

Yes, I usually just put the 0 delay as a placeholder as I am almost always changing it to try and overlap/align things in a certain way. I have really long TimeLines (30 objects) or so and many lines of code, including appendMultiple and insertMultiple, but still end up needing the delays. I know there should be an easier way but haven't found it yet. Perhaps, I need to explore the offset param more. Any organizational tips for looooooong TimelineMax/Lites?

 

I'd recommend breaking things into chunks and nest them as TimelineLites/Maxes. Then you can focus on each part individually. Like have methods that return TimelineLite instances and just build a global/parent one as you go, like mainTimeline.append( animateButtons() ), then mainTimeline.append( animateSquares(), -1), etc. I hope to post a more advanced tutorial on TimelineLite/Max stuff at some point, but I'm super busy so please be patient. :)

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