Timeline callbacks
This won't look entirely new to you because we've been working with animation callbacks for a while, but now we'll extend this logic to timelines. For example, knowing when a timeline is complete. By the end of this lesson, you will see how to implement callbacks in timelines.
Video Transcript
00:00All right, so let's continue. We're still in chapter six. I'm gonna bundle in a few topics
00:05At this stage, you should be familiar with the structure overall of tween light tween max
00:10So how do you know when the animation completes? That's probably the next question. Do you you can definitely continue adding?
00:16Events inside of your actually actual tween light, but what I recommend you do well not recommend
00:23But this is how you add uh, for example
00:25If you want to know when your animation completes you go into the creation of your new timeline and add that dynamic property
00:34And in that dynamic property i'm just going to add here on complete and then call an on complete function. So i'll call here on
00:42Tl complete so our timeline has completed and i'm just going to call this function right here
00:49private function
00:51And i'm going to call that and it doesn't have anything that's going through with it because we're not sending anything to it
00:56But we definitely could we could use the on complete params just the same way as we have done in
01:02Tween light and tween max now before we run this i'm just going to put here a little trace thing
01:07We are here and I want to do one more thing is I don't want to wait for this whole um,
01:13Animation to take place. So i'm going to go ahead and i'm going to add your new a new method
01:17And i'm just going to call the function c and i'm just going to push our position
01:22Now when we're working with the c actually let's work with progress
01:26Now sql i'll have to put an actual seconds value in this case
01:29I'm just going to put a value between zero and one where zero is the beginning and i'll just put your 0.8
01:34So we're really close to the ending of our animation
01:37And i'm going to go ahead and just run my application now
01:40Our applications should start from the last 20 20 percent of our animation. Perfect
01:45That's exactly what we wanted and here we see that we have our we are here
01:50Perfect. So let me just set it even to be 0.7. So we'll have a uh, oh
01:57That was a surprise I feel like another one's coming
02:00No, okay. We're good. All right. So now that we have our progress and uh, we're skipping through, uh, really quickly
02:07I'm gonna go ahead back into my on complete and now i'm gonna no it is coming
02:12Whoo
02:15That was a good one. All right. I think it's all out
02:18And what I want to do right now is once our on complete is done is I want to call our timeline
02:24Timeline object again, uh timeline light object and I want to call the reverse to animate backwards
02:31And i'll just call that reverse from where we are from wherever we are right now
02:36So let's give it a run and we're gonna expect it to start from 70 in because we use the progress
02:41function
02:43And we have our on complete so it's going to call the on tl complete when our animation completes
02:47And then we will have our reverse take place
02:50So if I run it just one more time, we're going to see that bam and it's going to go right backwards
02:56And basically animate all its way back to the beginning point which is absolutely wicked
03:03now if we wanted to we could just create here a yo-yo effect and although yo-yo does not exist inside of tween
03:09tween light
03:10Whoo, why do I always say it so hard? So tween line light but in tween light line max
03:17Just like between light tween max and tween light
03:20That's exactly the same type of extra features that exist in the max version versus the light version
