Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
forrestmaready

Creating absolute timing in a TimelineMax

Recommended Posts

Hello friends-

I'm trying to decide the best way to use TimelineMax (or Lite) to create a slideshow. I've created a standard timeline GUI that allows users to adjust timing, and need to create a timeline instance with corresponding time values. I've tried using offset and delay, but both are cumbersome to manipulate because they all affect the other tweens in the timeline.

 

Is there an easy method in TimelineMax I'm missing that allows me to set an absolute time to execute the tween? Something like...

 

timeline.append(TweenMax.to(pic1, 1, {alpha:0}), absTime:50);
timeline.append(TweenMax.to(pic2, 1, {alpha:0}), absTime:120);
timeline.append(TweenMax.to(pic3, 1, {alpha:0}), abstTime:200);

and so on... Absolute time would obviously be a variable. The first tween would start 50 frames after calling timeline.play(), the second 120 after start, etc... (assuming useFrames:true). Changing the tween duration would not affect the absolute timing at all (unless there was an overlap).

 

What's the best way to do this? Thanks in advance!!!

Link to comment
Share on other sites

That's exactly what the insert() and insertMultiple() methods are for - they allow you to define the EXACT time at which the tween begins. And if you want to base your timeline on frames instead of seconds, just define that through the vars object, like:

 

var timeline:TimelineLite = new TimelineLite({useFrames:true});
timeline.insert(TweenMax.to(pic1, 30, {alpha:0}), 50);
timeline.insert(TweenMax.to(pic2, 30, {alpha:0}), 120);
timeline.insert(TweenMax.to(pic3, 30, {alpha:0}), 200);

 

(notice I changed the duration of your tweens from 1 to 30 because I doubt you want the tween to only last 1 frame :) )

 

Oh, and you might want to consider using autoAlpha instead of alpha because Flash will render things faster if you set the visible property of objects to false when you don't want them to be visible (when alpha is 0 but visible is true, it still has to render them)

 

There are docs here: http://www.greensock.com/as/docs/tween/

Link to comment
Share on other sites

Thanks Jack! Much appreciated. When you set the timeline instance to useFrames=true, am I right to assume any Tweens pushed into that timeline will also default to useFrames=true?

Link to comment
Share on other sites

Thanks Jack! Much appreciated. When you set the timeline instance to useFrames=true, am I right to assume any Tweens pushed into that timeline will also default to useFrames=true?

 

Yep, exactly. As indicated in the docs, a tween's parent timeline always dictates its timing mode (frames or seconds).

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