02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Exploring all callbacks

Just like TweenLite and TweenMax so do TimelineLite,TimelineMax have callbacks. Call backs notify us when a specific event happens. We send into the library a function and it is triggered when the event occurs (Note: There can be only one function per callback). In this lesson, we will explore all the callbacks available in TimelineLite.

Video Transcript

00:00We are not new to callbacks. We haven't really looked at events really per se and we won't for a while
00:06but in this lecture
00:08we're going to talk about callbacks and just wrap up the whole topic of what callbacks are available for the
00:14Timeline light and how do we work with them?
00:17And that's exactly what we're going to see in this lecture learn now about
00:21basically 12 different properties that we could send into our timeline function that relate to
00:28Basically events or callbacks as we call them because they're actually a callback now
00:34Basically, we're not going to go in depth too deeply because we covered this very deeply throughout our courses in general
00:40So I just want you to be familiar with it know about it
00:44We said that there are four different types of callbacks that you could do with the timeline light
00:49One of them was update and on come on updated on complete which we already met and another two are the on start
00:56Which is also I'll call on on
01:00timeline start and we have also the on
01:05reverse
01:07complete come come come
01:10complete and
01:13We will call the on reverse complete function. I'll just on here add here a little bit of personalization on
01:20timeline reverse complete
01:22reverse
01:24complete
01:25reverse
01:27Rever
01:29Complete there you go. Let me just say this really quickly and I'll just add that into our
01:34Functions down here. So let me just create those functions really quickly
01:38so I'll just create here function on timeline start and
01:47I'm gonna create here really quickly function on
01:52Reverse start complete and I'll just add your a console dot log
01:57And I'll just put here that so we'll know that that's what was called and I'll just do the exact same thing for our on start and
02:08There we go
02:09There we go
02:11And if I just go ahead and save this go back to my application click on refresh if I didn't create any error as I
02:16Was doing that which I did at line 15. That's what happens when you type quickly and inefficiently
02:23Is because I pasted it. I basically I basically stole that on complete
02:27So I have to make sure that on complete still exists which on complete should be calling calling calling
02:34What should it be calling? I don't even remember already at this stage. It should be calling the on
02:39Mouse move on animate image complete. We just want to add that right back in there
02:45For some reason I deleted it. I didn't even notice I've done that
02:47So if we go ahead here and just click on refresh, hopefully that was the only bug
02:51And we could see that first of all if I comment this out
02:53we'll see that this function is called the on timeline start though basically the on start happens immediately when our timeline begins and
03:01If we let it play through
03:03The complete we already met but if we then let it reverse around and have it basically animate to the end
03:09We'll see that on the end will get that reverse complete as well
03:12If we wanted to create some sort of an action for them now
03:15I just wanted to do a reminder because we already met this I'm not going to dig deep into it at this stage and
03:20If we ever need it at any point we'll revert back to it and look into it
03:24So I'm just gonna put here a comment just as a reminder because these are things that we've seen in previous courses as well
03:30But they also exist for the timeline as well
03:33So every one of the on complete every one of the events has also an on
03:38Params, so in that case would be on complete params on update params on star params on a reverse params
03:45Which on reverse complete params that is and you could then send in parameters as an array
03:51So you basically would send in a value which would be an array and then that would turn into the values
03:56They would have in your function and you know what just for fun. Let's just add it to one of them
04:01So let's do let's just do it to the on start because that's gonna happen the first thing so we would have on start
04:08Params and I could send into an array one of them could be
04:13Self if we wanted to which we've learned about that curly curly bracket the word self
04:18Which would actually send its own self for example if you're gonna run it over and use a different scope
04:23and I could send another parameter hello and
04:27Literally all I really need to do is roll put a comma there
04:30All I really need to go is go to that on start add that parameter one with them was self one of them was
04:36Message and I literally could just comment it out and paste it there so we could see it
04:44And I'll paste also that I'll also put that self or even better as a reminder. I'll put here is the console
04:52console log does this equal self
04:56Which would lead us into the next topic that we're still in and if I click on refresh here
05:01We're gonna see that first of all we got here the hello that we had from the parameters
05:05And we also have that the item we send in really is itself
05:08Which leads us to the last topic that we have in this kind of like 12 methods really quickly
05:14Is that if we go back up here? We also have the on?
05:20scope
05:22So in this case we will put the item itself that we want to be in the scope so for example if we wanted to on
05:28Start params scope to be something else for example
05:32We wanted it to be maybe this image then probably would also want to move this image up so this image will be right
05:41Available right here above if we wanted to do something with that image
05:44And we wanted it to be the image for some reason. Oh not params. We said
05:49scope
05:50So if I save this go back in there
05:52And then this time around if we ask if this equals self
05:54We'll get the value of false because now this would be the actual image itself
05:58So if I go on here and click on refresh it would actually be false as you can see right here
06:03So that's it and literally we just covered not only these one two three four
06:09Functions of the on come on the on functions
06:12We also the four on params and the four on scopes you should be familiar with them play around with them
06:19Be really familiar with them if they look unfamiliar go back to our previous courses if you have access to them
06:25So you'll see them in action as we create things together
06:28last but not least to this topic is
06:31This is oh to completely true to timeline max, and it's also true to
06:37tween max really a lot of the functions are almost the same and the big a
06:42Few functions and properties that exist in time in tween light and tween max are there and have no real meaning
06:49Until you're actually working with the timeline itself, so now that we're working with the timeline
06:54We're going to be jumping back and forth between the timeline and the actual tweens to see what they mean in the tweens itself
06:59Because it's going to give us a bigger picture and a better understanding of how to control things on the timeline
07:05But we're not going to repeat every single one of these items when we move on to tween max
07:10And there'll be more properties of the timeline max
07:13Assume the same logic here because the logic is really really consistent that the guys at green sock Jack and
07:20Carl did a really really great job of keeping things really in
07:25Order that is very logical and throughout the whole experience and throughout the whole libraries once you get that logic and when you're in that flow
07:32You find the same language and terminologies over and over and over all right
07:37So that's it for this topic and we're going to go back in the next lesson
07:40Back into the actual add and look at a couple more properties of the add command add method that is

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!